fix(dashboard): clear undo history#40569
Conversation
after hydrate to prevent crash on new dashboard
Code Review Agent Run #e27b24Actionable Suggestions - 0Filtered by Review RulesBito filtered these suggestions based on rules created automatically for your feedback. Manage rules.
Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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_DASHBOARDis inTRACKED_ACTIONSfor the undoable layout reducer, so the initial hydrate pushes a phantom entry ontodashboardLayout.past. The button's existingdisabled={undoLength < 1}check then resolves tofalse, and clicking Undo restores a pre-hydration empty layout, which crashesDragDroppable.render.Existing dashboards don't hit this because
handleEnterEditModealready dispatchesclearDashboardHistory()when the user enters edit mode. New dashboards skip that path (they mount directly with?edit=true).Fix: dispatch
clearDashboardHistory()immediately afterhydrateDashboard()inDashboardPage.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.

After: Undo disabled until the first layout change. No crash.

TESTING INSTRUCTIONS
+ Dashboard.ADDITIONAL INFORMATION