richardfogaca opened a new pull request, #36122:
URL: https://github.com/apache/superset/pull/36122
### SUMMARY
Fixes a bug where the "Save and go to dashboard" option becomes disabled
after changing a chart's visualization type.
**The Problem:**
When a user opens a chart from a dashboard and changes its visualization
type (e.g., Line Chart → Bar Chart), the dashboard context is lost. The Save
modal then shows a placeholder "Select a dashboard OR create a new one" instead
of the actual dashboard name, and the "Save & go to dashboard" option becomes
disabled.
**Root Cause:**
The `dashboardId` field was being dropped during the form data
transformation process when switching visualization types. This happened in
`standardizedFormData.ts` where:
- `dashboardId` is not a form control, it's just a regular field that
stores the dashboard context
- When `getFormDataFromControls()` builds the new form data, it only
includes fields that have corresponding controls
- The `dashboardId` wasn't in the `publicControls` array (fields that
should be preserved across viz changes)
- Even though public form data was collected, it was being overwritten
instead of preserved
**The Fix:**
Two small changes to
`superset-frontend/src/explore/controlUtils/standardizedFormData.ts`:
1. Added `dashboardId` to the `publicControls` array so it gets collected
during transformations
2. Spread `publicFormData` after `getFormDataFromControls()` so the
dashboard context is preserved and not overwritten
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**BEFORE:** After changing chart type, Save modal shows "Select a
dashboard OR create a new one" and "Save & go to dashboard" is disabled and
nothing shows on "Add to dashboard" field
<img width="1254" height="694" alt="Interactive Pivot Table 2025-11-12
22-38-23 (1)"
src="https://github.com/user-attachments/assets/54eb7b7b-b832-41b4-b25c-236126d9f703"
/>
**AFTER:** Save modal correctly displays the dashboard name and "Save & go
to dashboard" remains enabled and "Add to dashboard" field shows the proper
content
<img width="667" height="468" alt="Screenshot 2025-11-14 at 16 59 46"
src="https://github.com/user-attachments/assets/cdf7b8ff-104f-4812-b377-7f9894b118b0"
/>
### TESTING INSTRUCTIONS
1. Open a dashboard and click into one of its charts to open Explore view
2. Click Save and verify the dashboard name appears with "Save & go to
dashboard" enabled (don't actually save)
3. Change the chart type to a different visualization (e.g., Line → Bar)
4. Click Save again
5. Verify the dashboard name still appears and "Save & go to dashboard" is
still enabled
### ADDITIONAL INFORMATION
- [x] Changes UI
--
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]