diff --git a/.changeset/pre.json b/.changeset/pre.json index 1aa18ab5b..a55ba8a63 100644 --- a/.changeset/pre.json +++ b/.changeset/pre.json @@ -142,6 +142,7 @@ "flux-store-solid2-migration", "focus-restore-primitive", "focus-solid2-migration", + "form-change-mode-dirty-gate-fix", "form-solid2-initial", "fullscreen-solid-2-migration", "geolocation-solid2-async-reactivity", diff --git a/packages/form/CHANGELOG.md b/packages/form/CHANGELOG.md index 1c096efbb..bebc596d9 100644 --- a/packages/form/CHANGELOG.md +++ b/packages/form/CHANGELOG.md @@ -1,5 +1,17 @@ # @solid-primitives/form +## 1.0.0-next.3 + +### Patch Changes + +- 1c687d9: Fix `createForm`'s default `validateOn: "change"` mode showing a field's error immediately on mount, before the user had touched it. `error()` was wired directly to the raw, ungated validation result for `"change"` mode, so any field whose initial value failed validation (e.g. a required field starting empty) rendered errored from the first paint. + + `"change"` mode's validator error is now gated on per-field dirtiness (`value() !== initial`) — hidden until the field's value actually changes, and hidden again if it's changed back to the initial value. `blur`/`submit` modes are unaffected (still gated on `touched()`/`submitted()` respectively). + + Fixing this also surfaced a second, separate bug: the gating was applied to the _combined_ raw error, which included any `setError()`-injected external error (e.g. a server-side validation message) — so an external error set on a pristine `"change"`-mode field was incorrectly hidden too. External errors are now always shown immediately regardless of mode/dirty/touched/submitted state, matching their documented purpose (`setError`: "Inject an external error (e.g. from a server response)"). + + `form.errors()` and `form.valid()` are unaffected either way — both were already, and remain, ungated (true validity regardless of display timing). + ## 1.0.0-next.2 ### Patch Changes diff --git a/packages/form/deno.jsonc b/packages/form/deno.jsonc index d0cfac06b..05050fd0d 100644 --- a/packages/form/deno.jsonc +++ b/packages/form/deno.jsonc @@ -1,6 +1,6 @@ { "name": "@solid-primitives/form", - "version": "1.0.0-next.2", + "version": "1.0.0-next.3", "description": "Reactive form primitive for Solid.js with per-field signals, sync/async validation, validateOn control, and DOM binding.", "license": "MIT", "exports": "./src/index.ts", diff --git a/packages/form/package.json b/packages/form/package.json index a1dc57eba..8de1a5040 100644 --- a/packages/form/package.json +++ b/packages/form/package.json @@ -1,6 +1,6 @@ { "name": "@solid-primitives/form", - "version": "1.0.0-next.2", + "version": "1.0.0-next.3", "description": "Reactive form primitive with per-field signals, sync/async validation, validateOn control, and DOM binding.", "author": "David Di Biase ", "contributors": [],