feat: close modals with browser back button on mobile (#257)
* feat: close modals with browser back button on mobile Create reusable useModalHistory hook that pushes history state when a modal opens and listens for popstate to close it. Apply to ReportModal, ClearMissedConfirm, ExportModal, ImportConfirm, and all modals using ConfirmModal/ShareDialog/Auth/ExportModal base components. Escape key handling was already in place for desktop. Closes #253 * fix: update tests for renamed button labels and missing useModalHistory mock
This commit is contained in:
@@ -30,7 +30,7 @@ describe("ReportModal", () => {
|
||||
render(<ReportModal isOpen={true} onClose={onClose} medications={[createMedication()]} />);
|
||||
|
||||
expect(screen.getByText(/report\.title/i)).toBeInTheDocument();
|
||||
fireEvent.click(screen.getByRole("button", { name: /common\.cancel/i }));
|
||||
fireEvent.click(screen.getByRole("button", { name: /common\.close/i }));
|
||||
expect(onClose).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user