FrancescoCastaldi opened a new pull request, #44945:
URL: https://github.com/apache/superset/pull/44945
### SUMMARY
`RadioButtonControl` previously wired `onChange` in two places:
1. On the `<Radio.Group>` container (`onChange={e =>
onChange(e.target.value)}`)
2. In the `onClick` handler on each `<Radio.Button>` (`onClick={e => {
e.currentTarget?.focus(); onChange(val); }}`)
Because of this duplicate wiring:
- Selecting an unselected radio option fired `onChange` twice with the same
value, causing redundant dispatches and re-renders in Explore controls (control
panel, ColumnConfig form items, MapView, ZoomConfig).
- Clicking an already-selected radio option fired `onChange` through the
button's `onClick` even though the selection did not change.
This PR keeps `onChange` handling exclusively on `<Radio.Group>` and retains
focus management (`e.currentTarget?.focus()`) in the button `onClick` handler
without invoking `onChange`.
### TESTING INSTRUCTIONS
1. Run automated unit tests:
```bash
npm test --
packages/superset-ui-chart-controls/test/shared-controls/components/RadioButtonControl.test.tsx
```
2. Verify all 35 tests pass, confirming:
- `onChange` is called exactly once when clicking an unselected option
- `onChange` is not called when clicking an already-selected option
- Focus is still correctly set on click
### ADDITIONAL INFORMATION
- [x] Has associated issue: Fixes #44921
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration
- [ ] 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]