Skip to content

Commit a1e7c8a

Browse files
committed
revert closeAttachmentPicker usage and change func
1 parent c0b6dce commit a1e7c8a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/components/MessageInput/MessageInput.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,17 +248,17 @@ const MessageInputWithContext = <
248248
} = useAttachmentPickerContext();
249249

250250
/**
251+
* Mounting and un-mounting logic are un-related in following useEffect.
251252
* While mounting we want to pass maxNumberOfFiles (which is prop on Channel component)
252253
* to AttachmentPicker (on OverlayProvider)
254+
*
255+
* While un-mounting, we want to close the picker e.g., while navigating away.
253256
*/
254257
useEffect(() => {
255258
setMaxNumberOfFiles(maxNumberOfFiles ?? 10);
256-
}, []);
257259

258-
/**
259-
* While un-mounting, we want to close the picker e.g., while navigating away.
260-
*/
261-
useEffect(() => closeAttachmentPicker, [closeAttachmentPicker]);
260+
return closeAttachmentPicker;
261+
}, []);
262262

263263
const selectedImagesLength = selectedImages.length;
264264
const imageUploadsLength = imageUploads.length;

src/contexts/messageInputContext/MessageInputContext.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,9 +577,7 @@ export const MessageInputProvider = <
577577
};
578578

579579
const closeAttachmentPicker = () => {
580-
if (selectedPicker) {
581-
setSelectedPicker(undefined);
582-
}
580+
setSelectedPicker(undefined);
583581
closePicker();
584582
};
585583

0 commit comments

Comments
 (0)