-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Initial Data for Bound Required Input Fields is 'undefined' #1233
Comments
Ah, interesting. When this has come up previously we've decided that setting text fields to Question is whether we should consider this a breaking change for semver purposes, or a bugfix? |
Thanks for taking a look at this. If this was a behavior that was previously agreed upon, then I suspect this counts as a breaking change, as much as I'd rather it count as a bugfix. 😒 I'm afraid I'm missing some context here: why would one wish to enforce initial data on a form? In particular, I'm building an authentication form (and assuming a new or unrecognized user). The extra code to set the fields to I really enjoying Svelte, FWIW. Thanks for putting this all together! |
Dropped the ball on this (sorry) but adding an updated REPL link: https://svelte.dev/repl?version=3.0.0-beta.28&gist=450f0a76e46ca4b2eb38a00d1c6ca7bf I think we'll be able to get away with calling this a bugfix (i.e. semver minor/patch) since it's hard to imagine someone relying on an |
Finally fixed, in 3.9.0. Thanks! |
Please, reopen it. The issue takes place again in Svelte v3.44.2 |
I believe this is a bug, but it may be a request for more documentation. Apologies if I'm posting this in the wrong spot.
Two-way binding an input field causes browsers to display the text
'undefined'
.In the Two-Way Binding section of the documentation, readers are provided an example of form handling in Svelte in the REPL. In the example, the input field's initial value is
'undefined'
.I sought to work around the problem by providing default data (in this case, an empty string). Unfortunately, this causes a different problem: Firefox sets input fields to the
:invalid
style state when JavaScript sets the value to''
on required field, or if the string does not validate (such as withtype="email"
). You can see this in this REPL (you will need to use Firefox to see the error).I believe this is a bug: I expect an undefined variable in a two-way binding scenario not to write
'undefined'
to the field it is found to. Using default data is not desirable because of Firefox's behavior (leads to surprising UX). Workarounds involve losing HTML5 attributes (required
andtype="email"
) or else avoiding the two-way binding, both of which require more work on the part of the developer using Svelte.The text was updated successfully, but these errors were encountered: