Skip to content

Commit

Permalink
Merge pull request #26045 from Expensify/hayata-fix-base-modal
Browse files Browse the repository at this point in the history
Fix BaseModal
  • Loading branch information
Hayata Suenaga authored Aug 28, 2023
2 parents c029dc5 + 3744439 commit d09a1b6
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/components/Modal/BaseModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,18 @@ function BaseModal({
ComposerFocusManager.setReadyToFocus();
}
},
// eslint-disable-next-line react-hooks/exhaustive-deps -- adding onModalHide to the dependency array causes too many unnecessary rerenders
[shouldSetModalVisibility],
[shouldSetModalVisibility, onModalHide, fullscreen],
);

useEffect(() => {
Modal.willAlertModalBecomeVisible(isVisible);

// To handle closing any modal already visible when this modal is mounted, i.e. PopoverReportActionContextMenu
Modal.setCloseModal(isVisible ? onClose : null);
}, [isVisible, onClose]);

return () => {
useEffect(
() => () => {
// Only trigger onClose and setModalVisibility if the modal is unmounting while visible.
if (isVisible) {
hideModal(true);
Expand All @@ -90,8 +91,10 @@ function BaseModal({

// To prevent closing any modal already unmounted when this modal still remains as visible state
Modal.setCloseModal(null);
};
}, [hideModal, isVisible, onClose]);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[],
);

const handleShowModal = () => {
if (shouldSetModalVisibility) {
Expand Down

0 comments on commit d09a1b6

Please sign in to comment.