From f8989810392237754a6c15f8bb70defe2345b18a Mon Sep 17 00:00:00 2001 From: Claude Code Date: Sat, 18 Jul 2026 14:18:36 -0700 Subject: [PATCH] fix(dashboard): offer Exit edit mode when there is nothing to discard Follow-up to #40832, which disabled the Discard button when a dashboard edit session has no unsaved changes. That fixed the misleading label but left the toolbar with no way back to view mode on a pristine session (Save and Discard both disabled, and the actions menu has no exit item). Keep the button always enabled instead, labeled Discard when there are unsaved changes and Exit edit mode when there are none. The handler is unchanged in both cases: it drops the ?edit param and returns to view mode. Co-Authored-By: Claude Fable 5 --- .../src/dashboard/components/Header/Header.test.tsx | 12 +++++++++--- .../src/dashboard/components/Header/index.tsx | 7 ++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/superset-frontend/src/dashboard/components/Header/Header.test.tsx b/superset-frontend/src/dashboard/components/Header/Header.test.tsx index 98397ec60750..6a6e5e419ede 100644 --- a/superset-frontend/src/dashboard/components/Header/Header.test.tsx +++ b/superset-frontend/src/dashboard/components/Header/Header.test.tsx @@ -522,12 +522,15 @@ test('should disable both buttons when no actions available', () => { expect(onRedo).not.toHaveBeenCalled(); }); -test('should render the "Discard" button as disabled', () => { +test('should render an enabled "Exit edit mode" button when there are no unsaved changes', () => { setup(editableState); - expect(screen.getByRole('button', { name: /discard/i })).toBeDisabled(); + expect(screen.getByRole('button', { name: /exit edit mode/i })).toBeEnabled(); + expect( + screen.queryByRole('button', { name: /discard/i }), + ).not.toBeInTheDocument(); }); -test('should enable the "Discard" button when there are unsaved changes', () => { +test('should render an enabled "Discard" button when there are unsaved changes', () => { const unsavedState = { ...editableState, dashboardState: { @@ -537,6 +540,9 @@ test('should enable the "Discard" button when there are unsaved changes', () => }; setup(unsavedState); expect(screen.getByRole('button', { name: /discard/i })).toBeEnabled(); + expect( + screen.queryByRole('button', { name: /exit edit mode/i }), + ).not.toBeInTheDocument(); }); test('should render the "Save" button as disabled', () => { diff --git a/superset-frontend/src/dashboard/components/Header/index.tsx b/superset-frontend/src/dashboard/components/Header/index.tsx index ca3b87501f93..283ff04a112a 100644 --- a/superset-frontend/src/dashboard/components/Header/index.tsx +++ b/superset-frontend/src/dashboard/components/Header/index.tsx @@ -722,13 +722,14 @@ const Header = (): JSX.Element => {