[EuiFieldNumber] Default to step="any" and check native validity on blur#6760
[EuiFieldNumber] Default to step="any" and check native validity on blur#6760cee-chen merged 4 commits intoelastic:mainfrom
step="any" and check native validity on blur#6760Conversation
- so that reported tooltips don't disappear immediately on outside click
|
@1Copenut do you mind reviewing this since you have context from our rubber ducky session yesterday? |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6760/ |
… `aria-invalid` - I was previously being a little hesitant about checking for undefined to allow consumers to override native invalid state if possible, but on second thought this makes no sense as the other invalid states use `||`
|
@1Copenut I should have addressed the Also, the staging link in the PR description is fixed now 🤦 |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_6760/ |
1Copenut
left a comment
There was a problem hiding this comment.
👍 LGTM! I did some testing with keyboard and VO and NVDA with preferred browsers. All behaved correctly. I also found some interesting tidbits about e as a shorthand for "ten to the power of..." Screen readers announce this correctly and the input is valid as long as e is followed by a number. I'll post some screenshots in a comment for posterity.
|
Very cool testing! I'll fly us all out in-person for celebratory drinks if the day ever comes that a user in Kibana needs |
## Summary `@elastic/eui@79.0.1` ⏩ `@elastic/eui@80.0.0` --- ## [`80.0.0`](https://github.com/elastic/eui/tree/v80.0.0) - Improved the contrast ratio of meta labels within `EuiSelectableTemplateSitewide` to meet WCAG AA guidelines. ([#6761](elastic/eui#6761)) - Added `vulnerabilityManagementApp` glyph to `EuiIcon` ([#6762](elastic/eui#6762)) - Added `logoVulnerabilityManagement` icon to `EuiIcon` ([#6763](elastic/eui#6763)) - Added `onPanelChange` callback to `EuiContextMenu` to provide consumer access to `panelId` and `direction`. ([#6767](elastic/eui#6767)) **Bug fixes** - Fixed `EuiComboBox` so `append` and `prepend` icon buttons are full height and vertically centered. ([#6766](elastic/eui#6766)) - Improved the uniformity of dropdown components by hiding the dropdown icon of disabled `EuiComboBox`s. ([#6768](elastic/eui#6768)) **Breaking changes** - `EuiFieldNumber` now defaults the `step` prop to `"any"` ([#6760](elastic/eui#6760)) - EUI now globally resets a default Chromium browser style that was decreasing the opacity of disabled `select` items. ([#6768](elastic/eui#6768)) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
## Summary `@elastic/eui@79.0.1` ⏩ `@elastic/eui@80.0.0` --- ## [`80.0.0`](https://github.com/elastic/eui/tree/v80.0.0) - Improved the contrast ratio of meta labels within `EuiSelectableTemplateSitewide` to meet WCAG AA guidelines. ([elastic#6761](elastic/eui#6761)) - Added `vulnerabilityManagementApp` glyph to `EuiIcon` ([elastic#6762](elastic/eui#6762)) - Added `logoVulnerabilityManagement` icon to `EuiIcon` ([elastic#6763](elastic/eui#6763)) - Added `onPanelChange` callback to `EuiContextMenu` to provide consumer access to `panelId` and `direction`. ([elastic#6767](elastic/eui#6767)) **Bug fixes** - Fixed `EuiComboBox` so `append` and `prepend` icon buttons are full height and vertically centered. ([elastic#6766](elastic/eui#6766)) - Improved the uniformity of dropdown components by hiding the dropdown icon of disabled `EuiComboBox`s. ([elastic#6768](elastic/eui#6768)) **Breaking changes** - `EuiFieldNumber` now defaults the `step` prop to `"any"` ([elastic#6760](elastic/eui#6760)) - EUI now globally resets a default Chromium browser style that was decreasing the opacity of disabled `select` items. ([elastic#6768](elastic/eui#6768)) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>



Summary
This PR is a follow-up to our existing EuiFieldNumber enhancement that added detection of native browser invalidity (#6741, 37c35ea).
Specifically, this PR is meant to address a comment left in a Kibana upgrade: elastic/kibana#155208 (comment).
Problem
Initially I thought the
:invalidissue onEuiFieldNumbersintended for decimal usage was already a problem beforehand. As it turns out, it had not been a visual problem becauseOn blur,

<input type="number">s with an undefined step update their validity status to accept the decimal as valid (default browser behavior). Screencap of said behavior:Our
:focusstyles (blue underline) were taking precedence over the:invalidstyles (red underline) and as such the invalid styling was never actually visible for decimal inputs. When we added the icon, the "invalid" state suddenly became visible. And then on blur, both focus and invalid styles would go away 💀Solution
This PR smooths out UX issues around the
stepbehavior for number inputs that contain decimals by defaulting tostep="any". After discussing and talking through the default browser behavior with @ryankeairns and @1Copenut, we determined that while EUI normally prefers to stick as close to browser implementation as possible, in this case the browser implementation felt clunky and bad, and this was clearly a case where changing the default would result in significant UX improvement.Note that with
step="any", the stepper increment/decrement still defaults to1which is the same behavior as before.This PR also adds the native validity check to
onBluras well, since browsers do apparently use that event (as well as change/keyup) to determine validity.QA
1General checklist
@defaultif default values are missing)and playground togglesjest andcypress tests- [ ] Checked for accessibility including keyboard-only and screenreader modes