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

fix: Updates number component to have more consistent UX #4897

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

thiessenp-cds
Copy link
Contributor

@thiessenp-cds thiessenp-cds commented Jan 2, 2025

Summary | Résumé

Updates number component to have more consistent UX.

Test

Create a form with a Number component. Try entering a number, it should be read correctly in a screen reader. Try entering not a number, form validation should fail for the Number component.

e.g.

Screen.Recording.2025-01-02.at.1.39.29.PM.mov

@thiessenp-cds thiessenp-cds linked an issue Jan 2, 2025 that may be closed by this pull request
Copy link
Contributor

github-actions bot commented Jan 2, 2025

@thiessenp-cds thiessenp-cds marked this pull request as ready for review January 2, 2025 19:17
@timarney
Copy link
Member

timarney commented Jan 2, 2025

Looks like it's accepting text chars ?

https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation

Screenshot 2025-01-02 at 2 27 34 PM

@thiessenp-cds
Copy link
Contributor Author

thiessenp-cds commented Jan 2, 2025

Looks like it's accepting text chars ?

https://developer.mozilla.org/en-US/docs/Web/HTML/Constraint_validation

Screenshot 2025-01-02 at 2 27 34 PM

Form validation would fail if it's not a number like in your example. Do you think more immediate validation or constraints would be helpful?

PS: Oh and Hi :)

@timarney
Copy link
Member

timarney commented Jan 2, 2025

I would say we'll need a product decision on this one

cc: @Abi-Nada @srtalbot

@thiessenp-cds
Copy link
Contributor Author

I would say we'll need a product decision on this one

cc: @Abi-Nada @srtalbot

I added a way to restrict user input to a number. Easy to remove if we decide not to include this.

@timarney
Copy link
Member

timarney commented Jan 7, 2025

Looks good -- @connorscarolyns will wait to approve until you have a look as well.

@connorscarolyns
Copy link

I think it works ok, It will be interesting to see how it tests. The screen reader announcing might be a bit confusing because it says it's a text field and to enter text, but nothing about it only accepting numbers.

@connorscarolyns
Copy link

I also notice that the UK does not use the pattern attribute, and has added a spellcheck false. Do we have reasoning for or against these differences?

@thiessenp-cds
Copy link
Contributor Author

The pattern attribute is used by JavaScript to validate what’s entered as a number but I can move/hide this in the JavaScript.

We can add spellcheck though if we restrict to only numbers it may not have much value. Still doesn’t hurt.

I think that’s a good point that the input is not announcing itself as a number. So a user could try to enter characters that are not a number and have no idea why it wasn’t entered.

One solution would be to add an aria-label and override the input semantics. This way it would announce as a number.
E.g. without an aria-label

Screenshot 2025-01-08 at 10 46 24 AM

E.g. with an aria-label=”number”
So the accessible name is changed to "number {label text}, edit text"

Screenshot 2025-01-08 at 10 46 47 AM

I wonder if the solution is becoming complex with the added JavaScript to restrict a number and aria to redefine an input text as a number? Vs. Just checking if an input is a number on submit and hopefully that input has hints it should be a number. I’m kind of on the fence.

@thiessenp-cds
Copy link
Contributor Author

@connorscarolyns actually what if we were to go ahead with the JavaScript to restrict entering to a number and adding an aria-label to identify the input as a number and see what happens in future user tests?

@connorscarolyns
Copy link

connorscarolyns commented Jan 8, 2025

@thiessenp-cds I like your approach. You may be right about overcomplicating things, but user testing will show if there are issues. I'm fine with it how it is and will log any further concerns when we retest the next time.

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 this pull request may close these issues.

Fabel testing: number field
3 participants