Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions src/components/Modal/BaseModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function BaseModal(
shouldPreventScrollOnFocus = false,
enableEdgeToEdgeBottomSafeAreaPadding = false,
shouldApplySidePanelOffset = type === CONST.MODAL.MODAL_TYPE.RIGHT_DOCKED,
canBeClosedByOtherModal = true,
}: BaseModalProps,
ref: React.ForwardedRef<View>,
) {
Expand Down Expand Up @@ -135,7 +136,9 @@ function BaseModal(
if (isVisible) {
willAlertModalBecomeVisible(true, type === CONST.MODAL.MODAL_TYPE.POPOVER || type === CONST.MODAL.MODAL_TYPE.BOTTOM_DOCKED);
// To handle closing any modal already visible when this modal is mounted, i.e. PopoverReportActionContextMenu
removeOnCloseListener = setCloseModal(onClose);
if (canBeClosedByOtherModal) {
removeOnCloseListener = setCloseModal(onClose);
}
}

return () => {
Expand All @@ -144,7 +147,7 @@ function BaseModal(
}
removeOnCloseListener();
};
}, [isVisible, wasVisible, onClose, type]);
}, [isVisible, wasVisible, onClose, type, canBeClosedByOtherModal]);

useEffect(() => {
hideModalCallbackRef.current = hideModal;
Expand Down
5 changes: 5 additions & 0 deletions src/components/Modal/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ type BaseModalProps = Partial<ReactNativeModalProps> &
* This is used to adjust the modal position when the Side Panel is open.
*/
shouldApplySidePanelOffset?: boolean;

/**
* Whether the modal can be closed by other modals
*/
canBeClosedByOtherModal?: boolean;
};

export default BaseModalProps;
Expand Down
4 changes: 4 additions & 0 deletions src/components/TestToolsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ function TestToolsModal() {
const isAuthenticated = useIsAuthenticated();
const route = getRouteBasedOnAuthStatus(isAuthenticated, activeRoute);

if (!isTestToolsModalOpen) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I understand this is good to add, but was this for code quality or to fix the bug?

return null;
}

return (
<Modal
isVisible={!!isTestToolsModalOpen}
Expand Down
1 change: 1 addition & 0 deletions src/components/ValidateCodeActionModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ function ValidateCodeActionModal({
useNativeDriver
shouldUseModalPaddingStyle={false}
animationInTiming={disableAnimation ? 1 : undefined}
canBeClosedByOtherModal={false}

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.

Hey guys!

After this change, the modal can no longer be closed with the Android back button. Is this an expected behavior?

@mananjadhav mananjadhav May 22, 2025

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No. We were discussing it here. Will prioritize to revert this one.

>
<ScreenWrapper
includeSafeAreaPaddingBottom
Expand Down