Skip to content
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

Auro-input tooShort validity not working #263

Open
cleung0305 opened this issue Aug 2, 2023 · 5 comments
Open

Auro-input tooShort validity not working #263

cleung0305 opened this issue Aug 2, 2023 · 5 comments

Comments

@cleung0305
Copy link

cleung0305 commented Aug 2, 2023

Auro-input tooShort validity not working

2.14.1

Please describe the bug

expected:

  1. Add auro-input in HTML, and set "minlength" to certain number.
  2. Input something with length < minlength.
  3. validity of element is 'TooShort'.
  4. shadowRoot element has validity.tooShort: true.

actual:

  1. Add auro-input in HTML, and set "minlength" to certain number.
  2. Input something with length < minlength.
  3. validity of element is 'valid'.
  4. shadowRoot element has validity.tooShort: true.

auro-input-issue

Reproducing the error on the docsite

None

Expected behavior

see description above

What browsers are you seeing the problem on?

No response

Additional context

No response

@cleung0305 cleung0305 added auro-input not-reviewed Issue has not been reviewed by Auro team members Type: Bug Bug or Bug fixes labels Aug 2, 2023
@cleung0305 cleung0305 changed the title [issue summary] Please verify version before submitting new issue Auro-input tooShort validity not working Aug 2, 2023
@blackfalcon
Copy link
Member

I was able to recreate this issue using the tests in the repo.

  it('minlength validity checked correctly', async () => {
    const el = await fixture(html`
      <auro-input maxlength="20" minlength="5" pattern="[0-9]{1,20}"></auro-input>
    `)

    el.value = 'a';
    await elementUpdated(el);
    expect(el.getAttribute('validity')).to.be.equal('tooShort');
    el.value = 'aaaaaaaaaaaaa';
    await elementUpdated(el);
    expect(el.getAttribute('validity')).to.be.equal('valid');
  });

This returned the following error

 ❌ auro-input > minlength validity checked correctly
      AssertionError: expected 'badInput' to equal 'tooShort'
      + expected - actual

      -badInput
      +tooShort

When I removed the pattern="[0-9]{1,20}" attribute, there was no issue with the code, and the test passed. It also should be noted that patterns are created in the element using the following code.

const pattern = new RegExp(`^${this.pattern}$`, 'u');

So the pattern you have in your element @cleung0305 may also be causing issues with this scenario as it's an invalid regex. @jason-capsule42 we should update the API docs to illustrate this fact.

@cleung0305 we are doing a lot of things with the pattern attribute, so it's easy to think that there is a clash between using pattern and minlength and not getting the proper return.

Thanks for this issue! The team will go over this ASAP.

@blackfalcon blackfalcon removed their assignment Aug 2, 2023
@blackfalcon
Copy link
Member

@Patrick-Daly-AA this issue is validated and ready to be addressed in the next available refinement session.

@jordanjones243
Copy link
Contributor

@blackfalcon Taking on this work and looking over the ticket, does the tooShort validity trump the badInput?

@Patrick-Daly-AA
Copy link

Putting this in the backlog until we complete our refactoring of form validation, and determine the hierarchy of validation error states: AlaskaAirlines/auro-formvalidation#12

@Patrick-Daly-AA
Copy link

Engineering to make a decision on hierarchy of error states to show when multiple error states trigger.

@jason-capsule42 jason-capsule42 removed Type: Bug Bug or Bug fixes not-reviewed Issue has not been reviewed by Auro team members labels Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants