sadpandajoe opened a new issue, #44921:
URL: https://github.com/apache/superset/issues/44921
### Bug description
`RadioButtonControl` wires the change in two places: `Radio.Group onChange`
and an `onClick` on every `Radio.Button`. Selecting a different option fires
both, so `onChange` runs at least twice with the same value (the click can also
reach the handler via both the label and the inner input). Clicking the
already-selected button also fires `onChange` through `onClick` even though
nothing changed. Controls that dispatch on change (control panel, ColumnConfig
form items, MapView/ZoomConfig mode switches) therefore dispatch duplicate
updates.
Steps to reproduce: render `RadioButtonControl` with an `onChange` spy and
click an unselected option: the spy is called more than once. Click the
selected option: the spy is still called.
Expected: one call per actual change.
### Where
`superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx`
- L72-L75 `<Radio.Group value={currentValue} onChange={e =>
onChange(e.target.value)}>`
- L96-L99 `onClick={e => { e.currentTarget?.focus(); onChange(val); }}`
(`VerticalRadioControl.tsx` only uses the Group `onChange`, so it is not
affected.)
### Suggested fix
Keep only the `Radio.Group onChange`; move the `focus()` call into a click
handler that does not call `onChange`.
### 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]