Skip to content

fix(explore): prevent duplicate onChange calls in RadioButtonControl (#44921) - #44945

Open
FrancescoCastaldi wants to merge 5 commits into
apache:masterfrom
FrancescoCastaldi:fix/radio-button-control-duplicate-onchange
Open

FrancescoCastaldi wants to merge 5 commits into
apache:masterfrom
FrancescoCastaldi:fix/radio-button-control-duplicate-onchange

Conversation

@FrancescoCastaldi

Copy link
Copy Markdown
Contributor

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:
    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

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #1f6470

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 7611488..7611488
    • superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx
    • superset-frontend/packages/superset-ui-chart-controls/test/shared-controls/components/RadioButtonControl.test.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

…invocation (apache#44921)

Signed-off-by: Francesco Castaldi <info@francescocastaldi.it>
…eady selected option (apache#44921)

Signed-off-by: Francesco Castaldi <info@francescocastaldi.it>
…n selections (apache#44921)

Signed-off-by: Francesco Castaldi <info@francescocastaldi.it>
… onClick handler (apache#44921)

RadioButtonControl previously wired onChange both on the Radio.Group wrapper
and in an onClick handler on each Radio.Button. Selecting an option triggered
both handlers with the same value, causing duplicate updates, redundant
renders, and duplicate Redux dispatches across Explore controls. Clicking an
already-selected option also triggered onChange redundantly.

Keep onChange handling exclusively on Radio.Group and retain focus management
in the button onClick handler.

Fixes: apache#44921
Signed-off-by: Francesco Castaldi <info@francescocastaldi.it>
…n tests (apache#44921)

Signed-off-by: Francesco Castaldi <info@francescocastaldi.it>
@FrancescoCastaldi
FrancescoCastaldi force-pushed the fix/radio-button-control-duplicate-onchange branch from 7611488 to 6463eaf Compare October 3, 2026 11:34
@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.28%. Comparing base (549508b) to head (6463eaf).

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #44945   +/-   ##
=======================================
  Coverage   82.28%   82.28%           
=======================================
  Files        2996     2996           
  Lines      185109   185115    +6     
  Branches    42834    42839    +5     
=======================================
+ Hits       152316   152322    +6     
  Misses      30031    30031           
  Partials     2762     2762           
Flag Coverage Δ
javascript 77.89% <ø> (+<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.

@bito-code-review

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

Copy link
Copy Markdown
Contributor

Code Review Agent Run #9fbd8c

Actionable Suggestions - 0
Review Details
  • Files reviewed - 2 · Commit Range: 3b0cd6d..6463eaf
    • superset-frontend/packages/superset-ui-chart-controls/src/shared-controls/components/RadioButtonControl.tsx
    • superset-frontend/packages/superset-ui-chart-controls/test/shared-controls/components/RadioButtonControl.test.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

@sadpandajoe
sadpandajoe self-requested a review October 5, 2026 17:11

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

RadioButtonControl calls onChange twice per selection (Radio.Group onChange plus a per-button onClick)

2 participants