-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Required input immediately marked invalid in Firefox with Ember 2.10 #14737
Comments
I'm willing to help fix this issue. Any pointers on where I should focus my search for the reason of this bug? |
Note that FireFox's implementation on the value + required attribute is actually correct. https://www.w3.org/TR/html5/forms.html#dom-input-value-value
|
Should be possible to fix in Glimmer, if it's a regression:
@martndemus Is validation the same as sanitization there? Dirty value would just mean it changed, whereas the validation should only kick in when either asking for it via the DOM API, or submitting the form afaik. |
This is just a hunch, but could it be that Glimmer first inserts the input into the DOM and only then sets the value to the bound property? That might trigger Firefox's validation. |
Hmm, this is surprising actually. Can someone double check if the same thing happens with plain JS? let el = document.createElement('input');
el.setAttribute('type', 'input');
el.setAttribute('required', 'true');
el.setAttribute('value', '');
document.body.appendChild(el); Does this have the same issue? |
No, the input element produced with that snippet doesn't have the same issue. |
OK, so the following is what we are doing internally today: let el = document.createElement('input');
el.value = '';
el.setAttribute('required', '');
document.body.appendChild(el); This shows the same issues as the twiddle. However, the following does work properly: let el = document.createElement('input');
el.setAttribute('value', '');
el.setAttribute('required', '');
document.body.appendChild(el); |
AFAICT the only fix for this would be to move to using attributes first, but that requires broader changes (see emberjs/rfcs#314). |
As mentioned by @rwjblue, fixing this has bigger implications that should be addressed by the linked to RFC. That is why I am marking this as wontfix and closing the issue. |
There seems to be a regression in Ember 2.10.0 in regards to required input fields.
In Firefox an input field
{{input value=foo required=true}}
is immediately marked as invalid (showing a red border around the field).This is not the case in Ember 2.9.0, where the field is only marked as invalid when trying to submit the form with the field being empty.
I created an Ember Twiddle to reproduce it.
The text was updated successfully, but these errors were encountered: