-
Notifications
You must be signed in to change notification settings - Fork 377
feat(NumberInput): add status validate icons #7806
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
feat(NumberInput): add status validate icons #7806
Conversation
|
Preview: https://patternfly-react-pr-7806.surge.sh A11y report: https://patternfly-react-pr-7806-a11y.surge.sh |
mcoker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Left a comment about the possibility of using <TextInput> if we can for the number input?
Also the validated example input is readonly - should we add an onChange handler so it matches the rest of the examples? I imagine the use case for this is the same as the default examples, except with a visual cue for when the value is within threholds.
d5ed2c0 to
4846be9
Compare
removing duplicate prop removing commented out code update snaps, reorder some props cleaning up example fix disabled numberinput
4846be9 to
44db5c6
Compare
mcoker
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! The only thing I noticed is if I try to enter a value in that input manually and hit backspace to enter a new number, it replaces the value with 0. That seems to just be an example thing in the onChange callback - up/down arrows work to change the number, so works for me!
@mcoker - You'll see the same thing here https://www.patternfly.org/v4/components/number-input#with-unit-and-thresholds It has to do with the fact we are limiting it to numbers (empty string isn't a number) between 0 and 10 in these cases. |
|
@mcarrano - in this PR i've utilized the textinput inside of the numberinput... however, there is logic within InputGroup is checking whether any (non select/textarea/textinput) children have an ID and then using that ID to set a describedby on the TextInput This makes sense if we are using a label with an ID.. but in this case, if we put an ID on the up/down buttons for the NumberInput it will use that ID in the describedby for the TextInput which doesn't really make sense. I can't imagine why a button would be used as a describedby. I've made it so that Button is one of the excluded types to get an ID from for describedby, but noticed there was actually a test wanting exactly that (a button ID used for describedby) https://github.com/patternfly/patternfly-react/blob/main/packages/react-core/src/components/InputGroup/__tests__/InputGroup.test.tsx#L16 I've updated the test to use a label instead. I've asked around a bit and it seems to be going back to you as the person who can make the decision on whether or not we can stop using a button ID in the inputGroup as the describedby for the input. |
@gitdallas IMO we should have a prop that disables that, and I'd argue making that the default when we can introduce that breaking change. The core examples show that same basic |
|
@mcoker - i agree about inputGroup should not be so opinionated, and found it odd to have it automatically generate describedby on a button id. As far as disabling that.. what if you did have multiple elements with IDs and you only wanted a specific one that wasn't the first (right now it just finds the first)? To me it would make more sense to just pass the value for describedby if you want it - but at this point that would be a breaking change. Perhaps we could add a formControlDescribedBy prop where if set it would use that and otherwise it could keep doing what it's doing? But then if you don't want a describedby even though you do want an ID on something within the inputgroup.. what then? empty string for formControlDescribedBy? allow formControlDescribedBy to be As far as the NumberInput - It's creating an |
|
IMO, we shouldn't build on top of the functionality, just add the option to disable it. If we have the option to pass an
If I understand the question, we have props for patternfly-react/packages/react-core/src/components/NumberInput/NumberInput.tsx Lines 45 to 55 in bb63f5f
|
|
@mcoker - this would override the describedby passed in |
|
@nicolethoen @tlabaj wanted to get your thoughts on the above convo. Looks like the enhacement is working as expected from a UX perspective, but it's unclear to me whether we should try to address the issue that @gitdallas raises about IDs. Thoughts? |
|
TLDR on coker and my exchange, our final options were narrowed down to:
this whole thing seems pretty edge casey, but need to figure something out |
|
I went ahead and just made it so that if someone adds aria-describedby to the input props, they don't get overridden by the existing feature. Seems least invasive for this edge case. Functionality can be seen in new InputGroup tests. |
packages/react-core/src/components/NumberInput/examples/NumberInput.md
Outdated
Show resolved
Hide resolved
packages/react-core/src/components/NumberInput/examples/NumberInput.md
Outdated
Show resolved
Hide resolved
packages/react-core/src/components/NumberInput/examples/WithStatus.tsx
Outdated
Show resolved
Hide resolved
tlabaj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far Dallas. Just one little comment.
tlabaj
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Dallas. LGTM
wise-king-sullyman
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect to me!
nicolethoen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I need to do more research about input type=number because I'm surprised that the default screen reader experience doesn't seem to include updating the user to the current value of the input when using the VO+arrow keys to change the value of the input. Same is true when updating the value using the + and - buttons. I think someone using a screen reader may need a little more information.
@thatblindgeye @jessiehuff do you have any more information about this scenario?
thatblindgeye
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is looking good! I had mainly some nitpicks below (let me know what you think).
In addition to @nicolethoen comment above, another issue is that the validation state only gets announced when navigating to the input, and even then only when the input is invalid (so a "warning" state won't get announced).
If the intent is to not have any validation text above/below the number input, a really quick option could be making the Number Input a live region and passing inputAriaLabel={validated} instead of "number input" (the value of the input could also be passed in, so that both the validation state and value get announced which could resolve the issue Nicole mentioned above).
packages/react-core/src/components/NumberInput/examples/WithStatus.tsx
Outdated
Show resolved
Hide resolved
@nicolethoen it looks like this is partially an issue with Chromium (https://stackoverflow.com/questions/48299571/screen-reader-cannot-read-number-input-values-on-chrome). With Firefox, changing the Number Input via Voice Over + arrow keys while in the input has the new value announced, though pressing the - or + buttons does not announce the new value. Safari acts similary to Firefox with some slight differences (works better when you just focus the input and press up/down arrow rather than "entering" the input via VO modifier + Shift + Down). It is definitely odd that the change in value doesn't get announced in Chrome by default, even when changing the value via the actual input and not our own +/- buttons. Adding aria live like I noted above seems to help resolve that in Chrome, but in Firefox the value ends up getting repeated by VO (pressing the minus button once would announce "89, 89, 89, 89" for me). So that may require a little more investigation. |
Co-authored-by: Eric Olkowski <70952936+thatblindgeye@users.noreply.github.com>
| className={css(styles.formControl)} | ||
| className={css( | ||
| styles.formControl, | ||
| validated === ValidatedOptions.success && formControlStyles.modifiers.success, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mcoker Should these formControlStyles be available in the number input. If so, should we open a core issue?
thatblindgeye
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Opened #7871 as a followup to the a11y issues since it looks like that will require more investigation to find a solution that resolves Chromium issues without introducing issues in other browsers.
What: Closes #7730
used
validatedproperty based on TextInput using that property for such styling.example: https://patternfly-react-pr-7806.surge.sh/components/number-input#with-status
Additional issues: