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

Type=Numeric does not prevent typing non-numeric characters (DOC ISSUE?) #120

Open
jason-capsule42 opened this issue Mar 7, 2024 · 3 comments · May be fixed by #122
Open

Type=Numeric does not prevent typing non-numeric characters (DOC ISSUE?) #120

jason-capsule42 opened this issue Mar 7, 2024 · 3 comments · May be fixed by #122
Assignees

Comments

@jason-capsule42
Copy link
Member

jason-capsule42 commented Mar 7, 2024

Please verify the version of auro-input you have installed

2.17.6

Please describe the bug

  1. Set type="numeric" on an auro-input
  2. Attempt to type non-numeric characters (E.g. abc)

Not that this may be a doc example issue. Likely "numeric" should just be "number" but we have a working example on the docsite that sets the type to "numeric".

Reproducing the error on the docsite

This issue is reproducible on the Auro docsite

Expected behavior

The HTML5 input type=numeric does not allow non-numeric characters to be entered. We should follow this pattern.

We already prevent typing non-numeric characters into inputs that are typed for dates and credit cards.

What browsers are you seeing the problem on?

No response

Additional context

No response

@jason-capsule42 jason-capsule42 added Type: Bug Bug or Bug fixes not-reviewed Issue has not been reviewed by Auro team members labels Mar 7, 2024
@jason-capsule42 jason-capsule42 changed the title Type=Numeric does not prevent typing non-numeric characters Type=Numeric does not prevent typing non-numeric characters (DOC ISSUE?) Mar 7, 2024
@blackfalcon
Copy link
Member

@jason-capsule42 when you say,

The HTML5 input type=numeric does not allow non-numeric characters to be entered. We should follow this pattern.

I am not sure what you are referencing. https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/number

I remember this being added with the Cleave.js work around credit card numbers and to be derived from the numericKeyboard object. I see that Cleave.js defined this in their API as well.

### `numericOnly`

A `Boolean` value indicates if it only allows numeric letters (0-9).

Ignored by `creditCard` and `date` shortcuts mode, the value will always be `true`.

`numericOnly` doesn't work on it's own, you have to either specify the shortcuts mode or `blocks` option to enable the formatter.

**Default value**: `false`

I see that the example is clearly broken and accepts alpha characters as well as numeric characters. I also see that the max attribute is not stopping the entry of more than 10 characters or throwing an error message when losing focus.

I do have concerns about redefining how the standard type number is implemented in the client if we are considering using type number as a custom element attribute.

@jason-capsule42
Copy link
Member Author

jason-capsule42 commented Mar 13, 2024

I see that the example is clearly broken and accepts alpha characters as well as numeric characters.

In the HTML5 input element type="number" prevents typing any non numeric character. The auro-input component is using type="numeric" which is not a thing at all in HTML5 input element. So when auro-input tries to apply it to the HTML5 input it has no affect on the behavior of the HTML5 input - thus, not blocking non-numeric characters. Our component should be following the HTML5 spec here.

The credit-card and date examples work because CleaveJS has it's own layer of preventing non-numeric characters being typed into those specific types. This is a heavy handed solution because I think CleaveJS is actually just cleaning up those characters rather than actually preventing them from being typed in the first place.

I also see that the max attribute is not stopping the entry of more than 10 characters or throwing an error message when losing focus.

That is because the validation library was built with the expectation that input was following the HTML5 standard of type="number" rather than making up it's own type. The auro-formvalidation utility has been updated since discovering this issue to validate on both type number as well as numeric to handle this issue.

Too add more context - I am not suggesting we remove the support for inputMode which does use numeric. I am saying that we conflated the valid inputMode="numeric" with type="numeric" which is wrong. We should continue to support inputMode="numeric" as it currently is used. We should just not be documenting examples that show type="numeric".

@jason-capsule42
Copy link
Member Author

Moving this back to triage - not sure how I mistakenly moved this one to work in progress before.

@Patrick-Daly-AA Patrick-Daly-AA removed the not-reviewed Issue has not been reviewed by Auro team members label Mar 15, 2024
@jason-capsule42 jason-capsule42 removed the Type: Bug Bug or Bug fixes label Oct 3, 2024
@jason-capsule42 jason-capsule42 removed their assignment Nov 15, 2024
@jordanjones243 jordanjones243 self-assigned this Dec 16, 2024
@jordanjones243 jordanjones243 transferred this issue from AlaskaAirlines/auro-input Dec 16, 2024
@jordanjones243 jordanjones243 linked a pull request Dec 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants