fix: preserve emptied remote number defaults - #16237
Open
vamshikrishnaramasamy wants to merge 1 commit into
Open
fix: preserve emptied remote number defaults#16237vamshikrishnaramasamy wants to merge 1 commit into
vamshikrishnaramasamy wants to merge 1 commit into
Conversation
|
Install the latest version of pnpm add https://pkg.svelte.dev/@sveltejs/kit/c/5e1f2d46e77f47fb2316a57e11d3b8de00e41dc3Open in Note This PR is from a fork. A maintainer must approve approve each commit before it can be built and installed. |
|
elliott-with-the-longest-name-on-github
added a commit
that referenced
this pull request
Aug 27, 2026
…ault only until edited (#16939) Since #16331 moved coercion into `coerce_form_value`, `handle_input` has stored the raw string of every typed value: `fields.value()` reported `'20'` while typing and `200` after a reset, and an emptied number field held `''` instead of `undefined`. Typed values are coerced again, the same way the submitter path already is. That re-exposes #15937: the default passed to `.as(type, default)` was re-applied whenever the field's value became `undefined` or `null`, so an emptied number input, or one cleared with `set()`, snapped back to its default. The default now only applies until the field is dirty. `defaultValue` and `defaultChecked` are unchanged, so reset still restores it. `dirty` is the modified signal from #16208; `touched` would drop the default on a tab-through. It is client-only, so SSR and a failed no-JS submission still render defaults. #16237 keys the same rule on key presence in the model instead. Fixes #15937.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #15937.
Remote form fields previously rendered their default whenever the backing value was
nullorundefined. Empty number inputs are converted toundefined, so deleting a defaulted number field caused the rendered value to snap back to the default.This distinguishes a missing field from a field that exists with an
undefinedvalue. Missing fields still render defaults, while emptied number fields render as empty strings.Tests:
pnpm --dir packages/kit exec vitest --config kit.vitest.config.js run src/runtime/form-utils.spec.jspnpm --dir packages/kit exec prettier --config ../../.prettierrc --check src/runtime/form-utils.js src/runtime/form-utils.spec.jspnpm --dir packages/kit exec tsc --noEmit --pretty false