ARBS-23 opened a new issue, #41246:
URL: https://github.com/apache/superset/issues/41246

   ### Bug description
   
   ### Description
   
   When creating a new dashboard via **+ Dashboard**, Superset opens the editor 
at `/superset/dashboard/<id>/?edit=true`. The **Undo** control is enabled even 
though no layout changes were made on the new dashboard. Clicking **Undo** 
throws:
   
   ```
   TypeError: Cannot read properties of undefined (reading 'type')
   ```
   
   This appears related to stale dashboard layout undo history from a 
previously edited dashboard. Undo history is cleared when entering edit mode 
via **Edit dashboard**, but not when navigating directly to a new dashboard in 
edit mode via **+ Dashboard**.
   
   ### Steps to reproduce
   
   1. Log in to Superset as any user with permission to create dashboards.
   2. Go to **Dashboards** list.
   3. Click **+ Dashboard** to create a new dashboard.
   4. Superset navigates to `/superset/dashboard/<new-dashboard-id>/?edit=true`.
   5. Without making any changes on the new dashboard, observe the **Undo** 
button in the header.
   6. Click **Undo**.
   
   ### Expected behavior
   
   - **Undo** should be **disabled** when there is no undoable action on the 
current dashboard.
   - Clicking **Undo** should not throw an error.
   - Undo should only apply to layout changes made on the **current** dashboard 
session.
   
   ### Actual behavior
   
   - **Undo** is **enabled** immediately on the new dashboard, before any user 
action.
   - Clicking **Undo** shows an unexpected error:
   
     ```
     Unexpected error
     TypeError: Cannot read properties of undefined (reading 'type')
     ```
   
   - The error can leave the UI in a broken state until navigating away or 
reloading.
   
   ### Video
   
   
https://github.com/user-attachments/assets/922f45ba-0b35-4225-b7b1-7ddcc1a1d4a9
   
   ### Environment
   
   | Item | Value |
   |------|--------|
   | Superset version | `apache/superset:6.1.0-py311` *(update if different)* |
   | Browser | Google Chrome (latest stable) |
   | OS | Windows 10 |
   | Reproduced on | Native Superset **+ Dashboard** flow 
(`/superset/dashboard/<id>/?edit=true`) |
   
   ### Additional context
   
   **Suspected root cause:** `dashboardLayout.past` (redux-undo history) is not 
cleared when opening a new dashboard directly in edit mode. Stale layout state 
from a previously edited dashboard remains in the Redux store. Undo then 
references components that do not exist on the new dashboard, leading to 
`undefined.type`.
   
   **Workaround (plugin-level):** Clear `@@redux-undo/CLEAR_HISTORY` on 
dashboard navigation when the dashboard id/slug changes.
   
   **Suggested fix:** Call `clearDashboardHistory()` (or equivalent) when:
   - A new dashboard is created and opened with `?edit=true`, and/or
   - The dashboard id changes during SPA navigation (not only when clicking 
**Edit dashboard**).
   
   ### Checklist
   
   - [x] I have searched the Superset issue tracker for duplicates
   - [x] I have provided clear steps to reproduce
   - [x] I have included a screen recording
   - [ ] I can reproduce on a standalone Superset instance (not only embedded)
   
   ### Screenshots/recordings
   
   
https://github.com/user-attachments/assets/922f45ba-0b35-4225-b7b1-7ddcc1a1d4a9
   
   ### Superset version
   
   6.1.0
   
   ### Python version
   
   3.11
   
   ### Node version
   
   18 or greater
   
   ### Browser
   
   Chrome
   
   ### Additional context
   
   _No response_
   
   ### Checklist
   
   - [x] I have searched Superset docs and Slack and didn't find a solution to 
my problem.
   - [x] I have searched the GitHub issue tracker and didn't find a similar bug 
report.
   - [ ] I have checked Superset's logs for errors and if I found a relevant 
Python stacktrace, I included it here as text in the "additional context" 
section.


-- 
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