Skip to content

Commit 8f4a0e3

Browse files
committed
refactor: Improve error handling and reset behavior in EditImageFormField
1 parent 5fbd69d commit 8f4a0e3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/Shared/Components/EditImageFormField/EditImageFormField.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,13 @@ const EditImageFormField = ({
6363
}
6464

6565
const handleReset = (newURL?: string) => {
66-
handleLastPreviewedURLChange(newURL ?? lastPreviewedURL)
67-
handleURLChange(newURL ?? lastPreviewedURL)
66+
const targetURL = newURL ?? lastPreviewedURL
67+
handleLastPreviewedURLChange(targetURL)
68+
handleURLChange(targetURL)
6869
handleError('')
6970
setIsEditing(false)
7071
setIsLoading(false)
72+
setEmptyPreviewURLErrorMessage('')
7173
}
7274

7375
const handleSuccess = () => {
@@ -111,7 +113,7 @@ const EditImageFormField = ({
111113

112114
const blob = await response.blob()
113115
if (blob.size > DEFAULT_MAX_IMAGE_SIZE) {
114-
throw new Error(`Please add an image smaller than ${DEFAULT_MAX_IMAGE_SIZE} bytes`)
116+
throw new Error(`Please add an image smaller than ${DEFAULT_MAX_IMAGE_SIZE / (1024 * 1024)} MB`)
115117
}
116118

117119
const src = URL.createObjectURL(blob)

0 commit comments

Comments
 (0)