Skip to content

fix: omit disabled options from multi-select changes - #14002

Merged
bluebill1049 merged 5 commits into
react-hook-form:masterfrom
wozhenbang2004:patch-7
Nov 7, 2026
Merged

bluebill1049 merged 5 commits into
react-hook-form:masterfrom
wozhenbang2004:patch-7

Conversation

@wozhenbang2004

Copy link
Copy Markdown
Contributor

Proposed Changes

Disabled options remain in selectedOptions, so changing a multiple select currently includes disabled options and options inside disabled optgroups in the form value and submission. It also lets required pass when only disabled options remain selected.

Filter disabled options when reading the DOM selection, consistently with checkbox and radio groups. The optgroup check follows the full ancestor chain, while the optional method call preserves custom select refs without DOM methods. Explicit defaultValues and setValue assignments remain intact.

Regression coverage includes selection and submission, required validation, explicit value assignments, and custom select refs.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Test plan

  • pnpm test --runInBand: 133 suites, 1,836 tests and 26 snapshots passed.
  • pnpm build, pnpm type, pnpm test:type, and pnpm lint passed.
  • Public createFormControl checks cover custom refs, dynamic disabled groups and explicit value assignments.
  • Browser automation is checked by repository CI.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new lint warnings
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

Ignore disabled options and disabled optgroup descendants when reading a multiple select. Preserve custom refs without DOM methods.
Cover selectedOptions objects that provide values without element methods.
Exercise DOM changes, submission, disabled optgroups, and explicit defaultValues and setValue assignments.
@bluebill1049
bluebill1049 merged commit 57d120c into react-hook-form:master Nov 7, 2026
6 checks passed
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