Visitar URL original
fix(explore): XAxisSortControl follows the value prop by ump45nose · Pull Request #44956 · apache/superset · GitHub
Skip to content

fix(explore): XAxisSortControl follows the value prop - #44956

Merged
rusackas merged 1 commit into
apache:masterfrom
ump45nose:fix/xaxis-sort-control-follows-prop
Oct 13, 2026
Merged

rusackas merged 1 commit into
apache:masterfrom
ump45nose:fix/xaxis-sort-control-follows-prop

Conversation

@ump45nose

Copy link
Copy Markdown
Contributor

SUMMARY

XAxisSortControl copied props.value into local state on first render (const [value, setValue] = useState(props.value)) and always passed that copy to SelectControl (value={value}). Its only useEffect ran on [props.shouldReset, props.value] but acted only when shouldReset was true, so a later change to props.value that does not remount the control never reached the render.

Direct selections still appeared to work because antd's inner Select keeps its own state, which masked the problem in the common path.

This drops the local copy and reads props.value directly, substituting undefined only while shouldReset is set (that is the value the reset path has to clear). props.onChange(undefined) in the effect is unchanged, so the reset behaviour the report describes still holds.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Not applicable: this is a state-propagation fix with no visual change, and it was reported at the component level with the UI repro not verified by the reporter either.

TESTING INSTRUCTIONS

Unit tests (component level, following the repro in the issue):

  1. XAxisSortControl.test.tsx (new):
    • renders the value it was given
    • follows the value prop when it changes
    • clears the value when shouldReset turns true

Verified

  • XAxisSortControl.test.tsx fails on master with exactly the reported symptom and passes with the fix (confirmed by stashing the fix and re-running: follows the value prop when it changes fails).
  • npx jest src/explore/components/controls --silent — 85 suites, 896 tests, all passing.
  • npx jest src/explore/components/ControlPanels src/explore/components/Property --silent — 1 suite, 23 tests passing.
  • npx oxlint --config oxlint.json --quiet on both changed files — clean.

Not verified

  • The Explore view in a browser: needs a running Superset instance and a chart config with the X-axis sort control, plus a way to push a new form_data value without remounting the control, which is what triggers it. I did not run this, so the UI-level repro from the issue remains unconfirmed by me.

Note: npx tsc --noEmit reports 608 pre-existing TS6305 errors ("Output file ... has not been built") in plugins/preset-chart-deckgl on a clean checkout; none are in the files I touched.

ADDITIONAL INFORMATION

`XAxisSortControl` copied `props.value` into local state on mount and
always passed that copy to `SelectControl`. A later change to
`props.value` (a `form_data` change that does not remount the control)
was therefore never rendered, and only `shouldReset` could clear it.
Direct selections hid the problem because the inner Select keeps its
own state.

Read `props.value` directly instead, and only substitute `undefined`
while `shouldReset` is set, which is what the reset path has to clear.

Fixes: apache#44918
@bito-code-review

bito-code-review Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Agent Run #34d4c8

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 010c962..010c962
    • superset-frontend/src/explore/components/controls/XAxisSortControl.test.tsx
    • superset-frontend/src/explore/components/controls/XAxisSortControl.tsx
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers an incremental AI Review.

  • /review full - Manually triggers a full AI Review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@codecov

codecov Bot commented Oct 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.29%. Comparing base (f2ff458) to head (010c962).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44956   +/-   ##
=======================================
  Coverage   82.29%   82.29%           
=======================================
  Files        2997     2997           
  Lines      185240   185239    -1     
  Branches    42867    42868    +1     
=======================================
+ Hits       152434   152441    +7     
+ Misses      30044    30036    -8     
  Partials     2762     2762           
Flag Coverage Δ
javascript 77.91% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rusackas rusackas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Classic stale-derived-state bug -- antd's inner Select masked it on the direct-click path, which is why it took a report to surface. Reading props.value straight through is the right call, and the shouldReset substitution keeps that behavior intact. Nice repro-first test too.

@rusackas
rusackas merged commit 85aa564 into apache:master Oct 13, 2026
83 checks passed
villebro pushed a commit that referenced this pull request Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XAxisSortControl keeps a stale local copy of value and ignores later changes to the value prop

3 participants