massucattoj opened a new pull request, #40569:
URL: https://github.com/apache/superset/pull/40569

   ### 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. 
   <img width="768" height="603" alt="Screenshot 2026-05-31 at 15 13 56" 
src="https://github.com/user-attachments/assets/dd8662e1-2f09-4dda-bc22-177cd5ab6015";
 />
   
   **After:** Undo disabled until the first layout change. No crash.
   <img width="821" height="601" alt="Screenshot 2026-05-31 at 15 13 21" 
src="https://github.com/user-attachments/assets/a00f67be-e479-48d9-9d14-77da9d10b3b5";
 />
   
   ### 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:
   - [x] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to