dosubot[bot] commented on issue #41246: URL: https://github.com/apache/superset/issues/41246#issuecomment-4752068867
<!-- Answer --> Hi @ARBS-23! I'm [Dosu](https://go.dosu.dev/dosubot) and I'm helping the Apache Superset team. Your analysis is spot-on. The root cause is confirmed in the code: when entering edit mode via the `?edit=true` URL parameter (as happens with **+ Dashboard**), `clearDashboardHistory()` is **not** called during hydration — whereas clicking the "Edit dashboard" button explicitly clears undo history [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/Header/index.jsx#L682-L685). Here's where the history clearing happens today: 1. **"Edit dashboard" button click** — calls `clearDashboardHistory()` [[1]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/Header/index.jsx#L682-L685) 2. **Empty state "Edit" button** in `DashboardBuilder.tsx` — also dispatches `clearDashboardHistory()` [[2]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx#L655-L657) 3. **After a successful save** — dispatches `UndoActionCreators.clearHistory()` [[3]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/actions/dashboardState.js#L207-L213) None of these cover the case where a dashboard is loaded with `?edit=true` from a fresh navigation or new dashboard creation. The hydration path at [dashboardStateReducer](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/actions/hydrate.js#L63-L65) sets `editMode` but never dispatches the history clear. **Suggested fix location**: In the hydration logic (or in the `Header` component's `useEffect` that detects initial edit mode), dispatch `clearDashboardHistory()` when: - The dashboard ID changes (SPA navigation), or - Edit mode is initialized via URL parameter The relevant action creator is already exported from `superset-frontend/src/dashboard/actions/dashboardLayout.js` [[4]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset-frontend/src/dashboard/actions/dashboardLayout.js#L270): ```javascript export const clearDashboardHistory = () => UndoActionCreators.clearHistory(); ``` As a note, [SIP-207](https://github.com/apache/superset/issues/39209) proposes migrating from `redux-undo` to `zundo` (Zustand temporal middleware) with feature-scoped stores, which would structurally prevent this class of stale-state bug. But that's a longer-term effort — the immediate fix of dispatching `clearDashboardHistory()` on dashboard ID change or `?edit=true` hydration is straightforward. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).* --- Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=86f9b723-b1f1-413d-94a1-9ba8eddad987) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset) -- 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]
