Skip to content

fix(dashboard): clear undo history#40569

Merged
kgabryje merged 1 commit into
apache:masterfrom
massucattoj:fix/dashboard-undo-empty-state-crash
Jun 2, 2026
Merged

fix(dashboard): clear undo history#40569
kgabryje merged 1 commit into
apache:masterfrom
massucattoj:fix/dashboard-undo-empty-state-crash

Conversation

@massucattoj
Copy link
Copy Markdown
Contributor

SUMMARY

On a brand-new dashboard, the Undo button was incorrectly enabled and crashed with TypeError: Cannot read properties of undefined (reading 'type') when clicked.

Root cause: HYDRATE_DASHBOARD is in TRACKED_ACTIONS for the undoable layout reducer, so the initial hydrate pushes a phantom entry onto dashboardLayout.past. The button's existing disabled={undoLength < 1} check then resolves to false, and clicking Undo restores a pre-hydration empty layout, which crashes DragDroppable.render.

Existing dashboards don't hit this because handleEnterEditMode already dispatches clearDashboardHistory() when the user enters edit mode. New dashboards skip that path (they mount directly with ?edit=true).

Fix: dispatch clearDashboardHistory() immediately after hydrateDashboard() in DashboardPage.tsx. Same helper, same pattern as the two existing call sites.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Before: The undo button appears right after create a new dashboard even if nothing was changed.
Screenshot 2026-05-31 at 15 13 56

After: Undo disabled until the first layout change. No crash.
Screenshot 2026-05-31 at 15 13 21

TESTING INSTRUCTIONS

  1. Open Superset, go to Dashboards.
  2. Click + Dashboard.
  3. Without making any edits, confirm the Undo button is disabled (same visual state as Redo).
  4. Add a chart via drag-and-drop, confirm Undo becomes enabled and works normally.

ADDITIONAL INFORMATION

  • Has associated issue: #107306
  • Required feature flags:
  • Changes UI
  • Includes DB Migration
  • Introduces new feature or API
  • Removes existing feature or API

  after hydrate to prevent crash on new dashboard
@dosubot dosubot Bot added the dashboard:editmode Related to te Dashboard edit mode label May 31, 2026
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 31, 2026

Code Review Agent Run #e27b24

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset-frontend/src/dashboard/containers/DashboardPage.test.tsx - 1
Review Details
  • Files reviewed - 2 · Commit Range: 7f2e4e4..7f2e4e4
    • superset-frontend/src/dashboard/containers/DashboardPage.test.tsx
    • superset-frontend/src/dashboard/containers/DashboardPage.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
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.97%. Comparing base (a621520) to head (7f2e4e4).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #40569   +/-   ##
=======================================
  Coverage   63.97%   63.97%           
=======================================
  Files        2654     2654           
  Lines      142753   142754    +1     
  Branches    32833    32833           
=======================================
+ Hits        91325    91326    +1     
  Misses      49870    49870           
  Partials     1558     1558           
Flag Coverage Δ
javascript 67.38% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 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.

@sadpandajoe sadpandajoe requested a review from kgabryje June 1, 2026 17:06
Copy link
Copy Markdown
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

LGTM

@kgabryje kgabryje merged commit ddb647c into apache:master Jun 2, 2026
69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dashboard:editmode Related to te Dashboard edit mode size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants