Skip to content

Required input immediately marked invalid in Firefox with Ember 2.10 #14737

Description

@galfert

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.

Activity

  1. changed the title [-]Required input immediately marked invalid in Firefox[/-] [+]Required input immediately marked invalid in Firefox with Ember 2.10[/+] on Dec 19, 2016
  2. galfert commented on Jan 17, 2017

    @galfert
    Author

    I'm willing to help fix this issue. Any pointers on where I should focus my search for the reason of this bug?

  3. raucao commented on May 26, 2017

    @raucao

    Should be possible to fix in Glimmer, if it's a regression:

    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.

    @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.

  4. galfert commented on May 26, 2017

    @galfert
    Author

    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.

  5. rwjblue commented on Dec 8, 2018

    @rwjblue
    Member

    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?

  6. galfert commented on Dec 14, 2018

    @galfert
    Author

    Does this have the same issue?

    No, the input element produced with that snippet doesn't have the same issue.

  7. rwjblue commented on Dec 21, 2018

    @rwjblue
    Member

    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);
  8. rwjblue commented on Dec 21, 2018

    @rwjblue
    Member

    AFAICT the only fix for this would be to move to using attributes first, but that requires broader changes (see emberjs/rfcs#314).

  9. locks commented on May 30, 2019

    @locks
    Contributor

    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.
    Thanks for the discussion everyone! Go comment on the RFC 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions