Skip to content

Fix ValidationGroup visited flag not propagating to fields#1294

Merged
mstijak merged 1 commit into
masterfrom
fix/1276-validationgroup-visited
May 19, 2026
Merged

Fix ValidationGroup visited flag not propagating to fields#1294
mstijak merged 1 commit into
masterfrom
fix/1276-validationgroup-visited

Conversation

@mstijak
Copy link
Copy Markdown
Member

@mstijak mstijak commented May 19, 2026

Issue

Fixes #1276.

When a ValidationGroup's visited binding is initialized to false and later set to true, the change is not propagated to child fields. If the binding is left uninitialized, it works.

Root cause

Field.disableOrValidate resolved the visited flag by coalescing data.visited into itself:

data.visited = coalesce(parentStrict ? parentVisited : null, data.visited, parentVisited);

The four sibling flags (disabled, readOnly, viewMode, tabOnEnterKey) each read a separate backing field (data._disabled, …) populated in prepareData; visited had none.

When a field's own bound data is unchanged, prepareData is skipped (the memoized selector returns a reference-equal rawData), so instance.data is the stale object from the previous render. disableOrValidate, re-invoked from explore on a parentVisited change, then reads the already-coalesced stale data.visited. Since coalesce treats false as a defined value, a stale false shadows the new parentVisited of true. With no initialization the stale value is undefined, which coalesce skips — hence "works without init".

Fix

Add a data._visited backing field in prepareData (mirroring _disabled, _readOnly, _viewMode, _tabOnEnterKey) and read it in disableOrValidate, so the field's own visited prop is preserved across renders.

Test

Added a regression test to ValidationGroup.spec.tsx. Verified it fails before the fix (AssertionError: false == true) and passes after. Full suite (508 tests) passes.

Field.disableOrValidate coalesced the resolved `visited` value back
into `data.visited`. When prepareData was skipped (the field's own
bound data unchanged), a stale resolved value shadowed an updated
`parentVisited`. This surfaced when a ValidationGroup's `visited`
binding was initialized to `false` and later set to `true`.

Add a `data._visited` backing field, mirroring `_disabled`,
`_readOnly`, `_viewMode` and `_tabOnEnterKey`, so the field's own
`visited` prop is preserved across renders.

Fixes #1276
@netlify
Copy link
Copy Markdown

netlify Bot commented May 19, 2026

Deploy Preview for cxjs-docs ready!

Name Link
🔨 Latest commit ddd5e68
🔍 Latest deploy log https://app.netlify.com/projects/cxjs-docs/deploys/6a0c31422c040e000864983f
😎 Deploy Preview https://deploy-preview-1294--cxjs-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mstijak mstijak merged commit a6beb72 into master May 19, 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.

Visited is not propagated from ValidationGroup to the TextField properly, when visited is initialised

1 participant