FrancescoCastaldi commented on code in PR #44945:
URL: https://github.com/apache/superset/pull/44945#discussion_r4400524417
##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx:
##########
@@ -100,7 +105,9 @@ export default function RadioButtonControl({
}`}
onClick={e => {
e.currentTarget?.focus();
- onChange(val);
+ if (!disabled && val === currentValue) {
+ onChange(val);
Review Comment:
Addressed in commit e6e69a36a1.
We aligned the component with the intended contract outlined in #44921:
1. Removed `onChange` entirely from `Radio.Button`'s `onClick`, leaving only
`e.currentTarget?.focus()`. Option selection is dispatched solely by
`Radio.Group.onChange`, ensuring exactly one callback per selection.
2. Clicking an already-selected option is now a clean no-op, avoiding
redundant state dispatches or unnecessary re-renders in consumers (such as
`map_view.mode`).
3. Rebased cleanly onto `upstream/master` and updated
`RadioButtonControl.test.tsx` to assert exact call counts
(`toHaveBeenCalledTimes(1)`) and verify that clicking an already-selected
option does not invoke `onChange`.
##########
superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx:
##########
@@ -58,22 +59,26 @@ function normalizeOption(option: RadioButtonOption):
RadioButtonOptionObject {
return option;
}
-export default function RadioButtonControl({
- value: initialValue,
- options,
- onChange,
- ...props
-}: RadioButtonControlProps) {
+export default function RadioButtonControl(props: RadioButtonControlProps) {
+ const {
+ value,
+ options,
+ onChange,
+ initialValue: _initialValue,
Review Comment:
Addressed in commit e6e69a36a1.
The unused `initialValue` prop and its associated test cases have been
completely removed. `RadioButtonControlProps` remains minimal with only
`value`, `options`, `onChange`, and standard header props.
--
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]