Skip to content

Commit 6451a9e

Browse files
adhorodyskiclaude
andcommitted
Scope shouldHandleNavigationBack override to FAB call site only
The previous fix hardcoded shouldHandleNavigationBack: false in the shared useCreateEmptyReportConfirmation hook, which broke browser-back dismissal for all callers (search, workspace selection, compose bar). Make it an opt-in parameter (default: true) and only disable it from the FAB's CreateReportMenuItem. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 872f034 commit 6451a9e

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/hooks/useCreateEmptyReportConfirmation.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ type UseCreateEmptyReportConfirmationParams = {
2121
onConfirm: (shouldDismissEmptyReportsConfirmation: boolean) => void;
2222
/** Optional callback function to execute when user cancels the confirmation */
2323
onCancel?: () => void;
24+
/** Whether the modal should push a history entry so browser-back dismisses it (default: true) */
25+
shouldHandleNavigationBack?: boolean;
2426
};
2527

2628
type UseCreateEmptyReportConfirmationResult = {
@@ -54,7 +56,12 @@ function ConfirmationPrompt({workspaceName, checkboxRef, onLinkPress}: {workspac
5456
);
5557
}
5658

57-
export default function useCreateEmptyReportConfirmation({policyName, onConfirm, onCancel}: UseCreateEmptyReportConfirmationParams): UseCreateEmptyReportConfirmationResult {
59+
export default function useCreateEmptyReportConfirmation({
60+
policyName,
61+
onConfirm,
62+
onCancel,
63+
shouldHandleNavigationBack = true,
64+
}: UseCreateEmptyReportConfirmationParams): UseCreateEmptyReportConfirmationResult {
5865
const {translate} = useLocalize();
5966
const {showConfirmModal, closeModal} = useConfirmModal();
6067
const workspaceDisplayName = policyName?.trim().length ? policyName : translate('report.newReport.genericWorkspaceName');
@@ -79,7 +86,7 @@ export default function useCreateEmptyReportConfirmation({policyName, onConfirm,
7986
title: `${translate('report.newReport.emptyReportConfirmationTitle')} `,
8087
confirmText: translate('report.newReport.createReport'),
8188
cancelText: translate('common.cancel'),
82-
shouldHandleNavigationBack: false,
89+
shouldHandleNavigationBack,
8390
prompt: (
8491
<ConfirmationPrompt
8592
workspaceName={workspaceDisplayName}

src/pages/inbox/sidebar/FABPopoverContent/menuItems/CreateReportMenuItem.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ function CreateReportMenuItem() {
112112
policyID: defaultChatEnabledPolicyID,
113113
policyName: defaultChatEnabledPolicy?.name ?? '',
114114
onConfirm: handleCreateWorkspaceReport,
115+
shouldHandleNavigationBack: false,
115116
});
116117

117118
return (

0 commit comments

Comments
 (0)