You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by di...@apache.org on 2025/10/01 14:43:08 UTC
(superset) branch master updated: fix(explore): close unsaved changes modal when discarding changes (#35307)
This is an automated email from the ASF dual-hosted git repository.
diegopucci pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new d8688cf8b1 fix(explore): close unsaved changes modal when discarding changes (#35307)
d8688cf8b1 is described below
commit d8688cf8b16be6296ac8ffcdcb64d94c16cc6a28
Author: Rafael Benitez <re...@gmail.com>
AuthorDate: Wed Oct 1 11:43:02 2025 -0300
fix(explore): close unsaved changes modal when discarding changes (#35307)
---
.../src/hooks/useUnsavedChangesPrompt/index.ts | 1 +
.../useUnsavedChangesPrompt.test.tsx | 29 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts b/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts
index b09adece6a..172e389c24 100644
--- a/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts
+++ b/superset-frontend/src/hooks/useUnsavedChangesPrompt/index.ts
@@ -41,6 +41,7 @@ export const useUnsavedChangesPrompt = ({
const manualSaveRef = useRef(false); // Track if save was user-initiated (not via navigation)
const handleConfirmNavigation = useCallback(() => {
+ setShowModal(false);
confirmNavigationRef.current?.();
}, []);
diff --git a/superset-frontend/src/hooks/useUnsavedChangesPrompt/useUnsavedChangesPrompt.test.tsx b/superset-frontend/src/hooks/useUnsavedChangesPrompt/useUnsavedChangesPrompt.test.tsx
index 63fecc293e..fd6b2a7c39 100644
--- a/superset-frontend/src/hooks/useUnsavedChangesPrompt/useUnsavedChangesPrompt.test.tsx
+++ b/superset-frontend/src/hooks/useUnsavedChangesPrompt/useUnsavedChangesPrompt.test.tsx
@@ -104,4 +104,33 @@ describe('useUnsavedChangesPrompt', () => {
expect(onSave).toHaveBeenCalled();
expect(result.current.showModal).toBe(false);
});
+
+ it('should close modal when handleConfirmNavigation is called', () => {
+ const onSave = jest.fn();
+
+ const { result } = renderHook(
+ () =>
+ useUnsavedChangesPrompt({
+ hasUnsavedChanges: true,
+ onSave,
+ }),
+ { wrapper },
+ );
+
+ // First, trigger navigation to show the modal
+ act(() => {
+ const unblock = history.block((tx: any) => tx);
+ unblock();
+ history.push('/another-page');
+ });
+
+ expect(result.current.showModal).toBe(true);
+
+ // Then call handleConfirmNavigation to discard changes
+ act(() => {
+ result.current.handleConfirmNavigation();
+ });
+
+ expect(result.current.showModal).toBe(false);
+ });
});