Skip to content

Comments

fix: update isValid when field disabled state changes#13231

Merged
bluebill1049 merged 2 commits intoreact-hook-form:masterfrom
a28689604:fix/update-isvalid-on-disabled-state-change
Jan 4, 2026
Merged

fix: update isValid when field disabled state changes#13231
bluebill1049 merged 2 commits intoreact-hook-form:masterfrom
a28689604:fix/update-isvalid-on-disabled-state-change

Conversation

@a28689604
Copy link
Contributor

@a28689604 a28689604 commented Jan 3, 2026

Proposed Changes

Problem

When toggling a field's disabled state in mode: 'onChange', isValid does not automatically recalculate. While disabled fields correctly skip validation, the form state becomes stale when the disabled state changes, causing isValid to not reflect the current validation state.

Example:

  • Start with required field empty → isValid = false
  • Disable that field → validation skips it , but isValid stays false
  • Expected: isValid = true (no enabled fields are invalid)

Solution

Modified _setDisabledField to detect when disabled state actually changes and trigger validation automatically.

Fixes #13176

Type of change

Please delete options that are not relevant.

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

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 warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes

- Auto-trigger validation in _setDisabledField when disabled state changes
- Add test for disabled state toggling with isValid in onChange mode

Fixes issue where isValid doesn't recalculate when a field's disabled
state changes, causing forms to show stale validation state.

Signed-off-by: a28689604 <[email protected]>
@a28689604 a28689604 force-pushed the fix/update-isvalid-on-disabled-state-change branch from 6589ca2 to d33e021 Compare January 3, 2026 11:10
@bluebill1049 bluebill1049 merged commit 65c78bc into react-hook-form:master Jan 4, 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.

issue: disabled field should not block validation / rules passed conditionally do not update the validation

2 participants