fix(explore): recompute currency_formats when dataset is saved from chart editor - #42478
Closed
SkinnyPigeon wants to merge 1 commit into
Closed
fix(explore): recompute currency_formats when dataset is saved from chart editor#42478SkinnyPigeon wants to merge 1 commit into
SkinnyPigeon wants to merge 1 commit into
Conversation
Contributor
|
Bito Review Skipped - Source Branch Not Found |
✅ Deploy Preview for superset-docs-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #42478 +/- ##
==========================================
- Coverage 65.25% 65.24% -0.01%
==========================================
Files 2795 2795
Lines 157639 157643 +4
Branches 36052 36053 +1
==========================================
- Hits 102869 102856 -13
- Misses 52793 52810 +17
Partials 1977 1977
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 ofmetric_name → Currencyused by all chart plugins (as camelCasecurrencyFormats) — is only computed once inhydrateExplore.tsat initial page load. WhenchangeDatasourceis dispatched after an inline dataset save, it passes the raw API response directly to Redux. The API response contains the updatedmetrics[].currencydata but never carries the pre-computedcurrency_formatsfield, so chart plugins receivecurrencyFormats: {}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 — derivecurrency_formatsfrommetrics[].currencybefore dispatching, exactly mirroring whathydrateExplore.tsdoes 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.
Updating.Currency.mp4
TESTING INSTRUCTIONS
Automated:
npx jest --testPathPatterns="datasourcesActions.test"— all 5 tests pass, including a new test that verifiescurrency_formatsis correctly derived from metric currencies whenchangeDatasourceis called.ADDITIONAL INFORMATION