@@ -70,30 +70,30 @@ const FeedbackModal = ({
7070 revokePreviewUrl ( screenshotPreview ) ;
7171 }
7272
73- if ( file ) {
74- // Validate file type
75- if ( ! isValidImageType ( file ) ) {
76- displayToast ( 'Invalid image type. Use PNG, JPG, WebP, or GIF.' ) ;
77- return ;
78- }
79-
80- // Validate file size
81- if ( ! isValidFileSize ( file ) ) {
82- displayToast (
83- `File too large. Maximum size is ${
84- MAX_SCREENSHOT_SIZE / 1024 / 1024
85- } MB.`,
86- ) ;
87- return ;
88- }
89-
90- setScreenshot ( file ) ;
91- setScreenshotPreview ( createPreviewUrl ( file ) ) ;
92- } else {
73+ if ( ! file ) {
9374 setScreenshot ( null ) ;
9475 setScreenshotPreview ( null ) ;
76+ return ;
9577 }
96- // eslint-disable-next-line react-hooks/exhaustive-deps
78+
79+ // Validate file type
80+ if ( ! isValidImageType ( file ) ) {
81+ displayToast ( 'Invalid image type. Use PNG, JPG, WebP, or GIF.' ) ;
82+ return ;
83+ }
84+
85+ // Validate file size
86+ if ( ! isValidFileSize ( file ) ) {
87+ displayToast (
88+ `File too large. Maximum size is ${
89+ MAX_SCREENSHOT_SIZE / 1024 / 1024
90+ } MB.`,
91+ ) ;
92+ return ;
93+ }
94+
95+ setScreenshot ( file ) ;
96+ setScreenshotPreview ( createPreviewUrl ( file ) ) ;
9797 } ,
9898 [ screenshotPreview , displayToast ] ,
9999 ) ;
@@ -193,16 +193,16 @@ const FeedbackModal = ({
193193 } ) ;
194194 } , [ category , description , screenshot , submitMutation , displayToast ] ) ;
195195
196- const isSubmitDisabled =
197- ! description . trim ( ) || isPending || isCapturing || isUploading ;
196+ const isOperationInProgress = isPending || isCapturing || isUploading ;
197+ const isSubmitDisabled = ! description . trim ( ) || isOperationInProgress ;
198198
199199 return (
200200 < Modal
201201 { ...props }
202202 onRequestClose = { onRequestClose }
203203 isDrawerOnMobile
204204 size = { ModalSize . Small }
205- shouldCloseOnOverlayClick = { ! isPending && ! isCapturing && ! isUploading }
205+ shouldCloseOnOverlayClick = { ! isOperationInProgress }
206206 >
207207 < Modal . Header title = "Send Feedback" />
208208 < Modal . Body className = "flex flex-col gap-4" >
@@ -233,7 +233,7 @@ const FeedbackModal = ({
233233 }
234234 size = { ButtonSize . Small }
235235 onClick = { ( ) => setCategory ( option . value ) }
236- disabled = { isPending || isCapturing || isUploading }
236+ disabled = { isOperationInProgress }
237237 >
238238 { option . label }
239239 </ Button >
@@ -251,7 +251,7 @@ const FeedbackModal = ({
251251 maxLength = { FEEDBACK_MAX_LENGTH }
252252 rows = { 6 }
253253 fieldType = "tertiary"
254- disabled = { isPending || isCapturing || isUploading }
254+ disabled = { isOperationInProgress }
255255 className = { {
256256 baseField : 'min-h-[150px]' ,
257257 } }
@@ -273,7 +273,7 @@ const FeedbackModal = ({
273273 variant = { ButtonVariant . Float }
274274 size = { ButtonSize . Small }
275275 onClick = { handleCaptureScreenshot }
276- disabled = { isPending || isCapturing || isUploading }
276+ disabled = { isOperationInProgress }
277277 icon = { < CameraIcon /> }
278278 >
279279 { isCapturing ? 'Capturing...' : 'Capture Screenshot' }
@@ -282,7 +282,7 @@ const FeedbackModal = ({
282282 variant = { ButtonVariant . Float }
283283 size = { ButtonSize . Small }
284284 onClick = { ( ) => fileInputRef . current ?. click ( ) }
285- disabled = { isPending || isCapturing || isUploading }
285+ disabled = { isOperationInProgress }
286286 icon = { < ImageIcon /> }
287287 >
288288 Upload Image
0 commit comments