Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
[],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ref: #58885, we should use hideModalRef instead of hideModal

);

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