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

   ### SUMMARY
   
   When editing a metric's currency via **Edit Dataset** from the chart editor, 
the chart preview did not reflect the new currency until the page was refreshed.
   
   **Root cause:** `currency_formats` — a derived map of `metric_name → 
Currency` used by all chart plugins (as camelCase `currencyFormats`) — is only 
computed once in `hydrateExplore.ts` at initial page load. When 
`changeDatasource` is dispatched after an inline dataset save, it passes the 
raw API response directly to Redux. The API response contains the updated 
`metrics[].currency` data but never carries the pre-computed `currency_formats` 
field, so chart plugins receive `currencyFormats: {}` and render without any 
currency formatting.
   
   **Why removal appeared to work:** Removing a currency also results in 
`currencyFormats: {}`, which is the correct outcome (no currency → no 
formatting), so it appeared to work immediately.
   
   **Fix:** In `changeDatasource` — the canonical entry point for all 
datasource updates — derive `currency_formats` from `metrics[].currency` before 
dispatching, exactly mirroring what `hydrateExplore.ts` does on initial page 
load. This ensures every caller gets consistent, up-to-date currency formatting 
without any component needing to know about this derived field.
   
   Fixes #42468
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   **Before:** Changing a metric's currency in Edit Dataset has no effect on 
the chart preview; a full page refresh is required.
   
   **After:** The chart preview immediately reflects the updated currency after 
saving the dataset.
   
   
https://github.com/user-attachments/assets/4641bf0f-cdc2-4c55-b5ea-91c340e038da
   
   
   ### TESTING INSTRUCTIONS
   
   1. Open an existing chart (e.g. a Big Number chart backed by a dataset with 
a metric).
   2. In Chart Source, click **...** beside the dataset name → **Edit Dataset**.
   3. Open the **Metrics** tab, expand a metric, and change its currency (e.g. 
from USD to EUR).
   4. Save the dataset and return to the chart preview.
   5. Verify the chart immediately renders with the updated currency symbol — 
no page refresh required.
   
   Automated: `npx jest --testPathPatterns="datasourcesActions.test"` — all 5 
tests pass, including a new test that verifies `currency_formats` is correctly 
derived from metric currencies when `changeDatasource` is called.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: #42468
   - [ ] Required feature flags:
   - [x] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] 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