Browse Source

fix(questions-list): handle optional tips sheet in hardware back stack cleanly

master
mortezaei 2 days ago
parent
commit
cf71fc9f65
  1. 9
      src/app/questions-list/questions-list-client.tsx
  2. 5
      src/components/Componentes/information-sheet.tsx

9
src/app/questions-list/questions-list-client.tsx

@ -63,15 +63,14 @@ export default function QuestionsListClient() {
// entries. Flutter calls __habibHandleHardwareBack() and we return false
// (meaning "I didn't handle it — you should close").
useHardwareBackHandler(() => {
if (isOptionalInfoSheetOpen) {
setIsOptionalInfoSheetOpen(false);
return true; // Handled: closed the tips sheet
}
if (activeSectionSlug) {
handleCloseSection();
return true; // Handled: closed the section sheet, do not close WebView
}
if (typeof window !== "undefined" && (window as any).HabibApp?.postMessage) {
(window as any).HabibApp.postMessage(
JSON.stringify({ action: "close_service" }),
);
}
return false; // Tell Flutter to close the WebView screen
});
const { dictionary: t, locale } = useI18n();

5
src/components/Componentes/information-sheet.tsx

@ -172,7 +172,10 @@ export function InformationSheet({
}, EXIT_ANIMATION_MS);
}, [isClosing, onClose]);
useHardwareBackHandler(closeSheet, isVisible && !isClosing);
useHardwareBackHandler(() => {
closeSheet();
return true;
}, isVisible && !isClosing);
const controls = { close: closeSheet };
const resolvedTitle = typeof title === "function" ? title(controls) : title;

Loading…
Cancel
Save