Skip to content

fix: focus the first enabled option in radio and checkbox groups - #13960

Merged
bluebill1049 merged 1 commit into
react-hook-form:masterfrom
charan-rathore:fix/first-enabled-group-focus
Oct 29, 2026
Merged

bluebill1049 merged 1 commit into
react-hook-form:masterfrom
charan-rathore:fix/first-enabled-group-focus

Conversation

@charan-rathore

Copy link
Copy Markdown
Contributor

Title: fix: focus the first enabled option in radio and checkbox groups

When the first registered radio or checkbox is disabled, error focus tries that option and stops without focusing an enabled option in the same group.

Find the first enabled group ref before calling the field action. The first enabled option keeps its current behavior. If every group option is disabled, focus can continue to the next invalid field. The regression tests also check that toggling form-wide disabled state still reenables every option.

Validation on current master: 130 test suites, 1,790 tests and 26 snapshots pass. Type checks, the package build, API Extractor and changed-file lint/format checks pass. Three regression cases fail with the original implementation and pass with the fix; two controls pass on both. A browser reproduction using current source confirms the enabled option receives focus.

The browser suite completed across three shards: 89 tests pass and one asyncStrictMode test fails. The same test also fails against current unpatched master under the same repeated two-worker check, with missing intermediate async values. An isolated base run passes, so this is an intermittent baseline failure, not a full browser-suite pass.

@bluebill1049
bluebill1049 merged commit b2c9288 into react-hook-form:master Oct 29, 2026
6 checks passed
bluebill1049 added a commit that referenced this pull request Oct 31, 2026
… groups (#13968)

setFocus always focused the first registered option of a radio or
checkbox group. When that option is disabled, focus() does nothing and
focus stays where it was. Error focus already skips disabled options
since #13960; setFocus now does the same, and still falls back to the
first option when every option is disabled.

Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: Bill <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants