This is an automated email from the ASF dual-hosted git repository.
rusackas 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 67924ad35e1 fix(dashboard): offer Exit edit mode when there is nothing
to discard (#42208)
67924ad35e1 is described below
commit 67924ad35e11ca8ab725a62ca7a221e3e1950e5f
Author: Evan Rusackas <[email protected]>
AuthorDate: Wed Jul 22 18:43:49 2026 -0700
fix(dashboard): offer Exit edit mode when there is nothing to discard
(#42208)
Co-authored-by: Claude Code <[email protected]>
---
.../src/dashboard/components/Header/Header.test.tsx | 12 +++++++++---
superset-frontend/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 98397ec6075..6a6e5e419ed 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 ca3b87501f9..283ff04a112 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 => {
<Button
css={discardBtnStyle}
buttonSize="small"
- disabled={!hasUnsavedChanges}
onClick={discardChanges}
buttonStyle="secondary"
data-test="discard-changes-button"
- aria-label={t('Discard')}
+ aria-label={
+ hasUnsavedChanges ? t('Discard') : t('Exit edit mode')
+ }
>
- {t('Discard')}
+ {hasUnsavedChanges ? t('Discard') : t('Exit edit mode')}
</Button>
<Button
css={saveBtnStyle}