sadpandajoe opened a new issue, #44918:
URL: https://github.com/apache/superset/issues/44918
### Bug description
`XAxisSortControl` initialises `useState(props.value)` and always passes
that local state to `SelectControl` (`{...props} value={value}`, local value
wins). The only effect that touches it runs on `[props.shouldReset,
props.value]` but only acts when `shouldReset` is true, so a later change to
`props.value` (set from outside the control, e.g. a form_data/state change that
does not remount the control) is never reflected in the displayed value. Direct
user selections still appear because the inner Select keeps its own state,
which hides the problem in the common path.
Steps to reproduce (component level): render with `value="a"`, re-render
with `value="b"`; the select still shows "a". UI-level repro through Explore
not verified.
Expected: displayed value follows `props.value`.
### Where
`superset-frontend/src/explore/components/controls/XAxisSortControl.tsx`
- L31 `const [value, setValue] = useState(props.value);`
- L32-L37 effect only handles `props.shouldReset`
- L42 `value={value}`
### Suggested fix
Drop the local state and pass `props.value` through (use `undefined` when
`shouldReset`), or sync with `useEffect(() => setValue(props.value),
[props.value])`.
### Found by
Found while adding React Testing Library coverage for Explore controls (all
line numbers are against `master` at `bc3698b5d6`).
--
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]