-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
feat: default values for form elements #14289
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: d4e836b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
preview: https://svelte-dev-git-preview-svelte-14289-svelte.vercel.app/ this is an automated message |
|
Rich-Harris
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like <select> elements aren't being reset correctly? I have to press the reset button twice for the state to update, even though the select itself updates immediately
WIP
closes #8220
closes #9230
This implements default values for form elements. These default values take effect when the
resetmethod of the surrounding form is invoked.inputwithvalue/checkedit'sdefaultValue/defaultCheckedforno handling forinputwithbind:groupit'schecked(hydration not working yet, not working for dynamic yet)bind:group, because too confusing / limitingselectit'sselectedon theoptionelements (hydration not working yet, not working for dynamic yet)Open questions:
defaultValue/defaultCheckedthe value of that takes precedence on the initial render in case thevalue/checkedvalue isundefined/null. That also means that in case ofbind:value/checkedthe default value will be propagated back to that variable. Ok?bind:group? It's tricky there because for a group of checkboxes, we currently require an array to be set (else you get runtime errors), and so the value isn't falsy, and the empty array could be on purpose / hard to say if the default checked should take precedence there initiallybind:group. That binding is kinda special in many ways and withbind:checked={get, set}we can likely provide a more robust/scalable/working across components solution anywaybind:valueon selects withmultiple, with same problem as forbind:groupon checkboxesmultiplethe initial selection is ignored, i.e. the array takes precedenceBefore submitting the PR, please make sure you do the following
feat:,fix:,chore:, ordocs:.Tests and linting
pnpm testand lint the project withpnpm lint