Skip to content

fix(dashboard): disable Discard button when there are no unsaved changes#40832

Merged
rusackas merged 5 commits into
apache:masterfrom
massucattoj:fix/dashboard-discard-no-changes
Jul 18, 2026
Merged

fix(dashboard): disable Discard button when there are no unsaved changes#40832
rusackas merged 5 commits into
apache:masterfrom
massucattoj:fix/dashboard-discard-no-changes

Conversation

@massucattoj

Copy link
Copy Markdown
Contributor

SUMMARY

The Discard button in the dashboard edit toolbar was always enabled, even on a freshly opened new dashboard with no changes. Clicking it suggested "discard this dashboard", but the handler only strips ?edit from the URL the dashboard itself stays persisted (the backend creates it eagerly at /dashboard/new/).

Scope note: the ticket description also mentions "Discarding should abort creation and not persist a dashboard." That is not addressed here it would require changing how /dashboard/new/ works (it
currently eagerly inserts a DashboardModel before any user interaction). Maybe worth a separate ticket?

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

  • Before
Screenshot 2026-06-06 at 14 45 47
  • After
Screenshot 2026-06-06 at 14 44 53

TESTING INSTRUCTIONS

  1. Open Superset → Dashboards → click + Dashboard.
  2. Without making any changes, confirm the Discard button is disabled (greyed out, not clickable).
  3. Edit the dashboard title (or drag in a chart). Confirm both Discard and Save become enabled.
  4. Click Discard → URL drops ?edit, returns to view mode.
  5. Re-enter edit mode without making changes → Discard is disabled again.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@dosubot dosubot Bot added change:frontend Requires changing the frontend dashboard:editmode Related to te Dashboard edit mode labels Jun 6, 2026
@bito-code-review

bito-code-review Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #e532df

Actionable Suggestions - 0
Additional Suggestions - 1
  • superset-frontend/src/dashboard/components/Header/Header.test.tsx - 1
    • Inconsistent testId usage · Line 527-527
      The Discard button has `data-test="discard-changes-button"` (Header/index.tsx:727) but this test uses `getByText` instead of `getByTestId`. Other button tests in this file (Undo/Redo at lines 352, 357, 369, 375, etc.) consistently use `getByTestId`. Using the testId improves test reliability and maintainability.
Review Details
  • Files reviewed - 2 · Commit Range: 06b051e..06b051e
    • superset-frontend/src/dashboard/components/Header/Header.test.tsx
    • superset-frontend/src/dashboard/components/Header/index.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.18%. Comparing base (4e098b6) to head (c0f7947).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #40832      +/-   ##
==========================================
- Coverage   65.19%   65.18%   -0.01%     
==========================================
  Files        2767     2767              
  Lines      156062   156062              
  Branches    35717    35717              
==========================================
- Hits       101741   101735       -6     
- Misses      52361    52367       +6     
  Partials     1960     1960              
Flag Coverage Δ
javascript 70.82% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the dashboard edit toolbar so the Discard action is disabled when the dashboard has no unsaved changes, aligning it with the existing Save button behavior and preventing “discard” from appearing actionable on a pristine edit session.

Changes:

  • Disable the Discard button when hasUnsavedChanges is false.
  • Update the Header unit test to assert the Discard button is disabled in that state.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
superset-frontend/src/dashboard/components/Header/index.tsx Disables the Discard button based on hasUnsavedChanges.
superset-frontend/src/dashboard/components/Header/Header.test.tsx Updates the related test expectation for the Discard button disabled state.

Comment thread superset-frontend/src/dashboard/components/Header/index.tsx
Comment thread superset-frontend/src/dashboard/components/Header/Header.test.tsx
Comment thread superset-frontend/src/dashboard/components/Header/Header.test.tsx
@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 871cfc5
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a2cbd426402040009733605
😎 Deploy Preview https://deploy-preview-40832--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@massucattoj
massucattoj requested a review from sadpandajoe June 13, 2026 02:28
@netlify

netlify Bot commented Jun 13, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 1dcf97f
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a2cc03f4348060008af82f3
😎 Deploy Preview https://deploy-preview-40832--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@bito-code-review

bito-code-review Bot commented Jun 13, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #472d7d

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 06b051e..1dcf97f
    • superset-frontend/src/dashboard/components/Header/Header.test.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

<Button
css={discardBtnStyle}
buttonSize="small"
disabled={!hasUnsavedChanges}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yousoph @kasiazjc with the Save and Discard both disabled if there are no changes, the header now has no way to exit edit mode. Are we okay with that or do we want to add another button to close or exit? Asking before I approve.

@rusackas

Copy link
Copy Markdown
Member

Thanks for tackling this, @massucattoj. As noted, sadpandajoe's question above still stands, with both Save and Discard disabled there's no way out of edit mode until you actually change something. I don't think we can merge until that's settled with @yousoph and @kasiazjc. Might be as simple as keeping Discard enabled (just relabeled) when there's nothing to discard, or maybe a separate "exit edit mode" action. Thoughts?

@massucattoj

Copy link
Copy Markdown
Contributor Author

@rusackas Yeah I think this needs a design call before we change anything. I'd rather wait for @yousoph and @kasiazjc to weigh in on @sadpandajoe question that guess at a solution here. I'll ping them on Slack in the next few days to unblock this.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should just plow ahead. It's a small, clean fix, and the two new tests lock in both button states. LG(enough)TM, approving, will merge once CI's green.

To close the loop on sadpandajoe's question above: I traced the Header, and it's true that with nothing changed there's no toolbar exit from edit mode, and the "..." menu doesn't have one either. But with nothing unsaved there's no navigation guard, so a refresh or any nav click gets you out. That seems like a smaller wart than a Discard button that discards nothing, so let's take this as-is. We'll put up a follow-up PR giving the pristine state an exit affordance, and @yousoph / @kasiazjc can steer the design from there.

@rusackas
rusackas merged commit 751f5eb into apache:master Jul 18, 2026
66 checks passed
@bito-code-review

Copy link
Copy Markdown
Contributor

Bito Automatic Review Skipped – PR Already Merged

Bito scheduled an automatic review for this pull request, but the review was skipped because this PR was merged before the review could be run.
No action is needed if you didn't intend to review it. To get a review, you can type /review in a comment and save it

@rusackas

Copy link
Copy Markdown
Member

Opened a follow-up on #42208 if anyone wants to take a looksee at that one :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:frontend Requires changing the frontend dashboard:editmode Related to te Dashboard edit mode size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants