Skip to content

Commit

Permalink
fix(number-field): add aria-valuetext to prevent VO announce percentage
Browse files Browse the repository at this point in the history
  • Loading branch information
bualoy-napat authored Jul 27, 2023
2 parents 48796fb + 1eb61fc commit 8e2a1e4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
```html
<input
aria-valuenow="0"
aria-valuetext="0"
autocomplete="off"
inputmode="decimal"
part="input"
Expand All @@ -33,6 +34,7 @@
```html
<input
aria-valuenow="0"
aria-valuetext="0"
autocomplete="off"
inputmode="decimal"
part="input"
Expand Down
2 changes: 2 additions & 0 deletions packages/elements/src/number-field/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ export class NumberField extends FormFieldElement {
* inputmode="decimal" - show decimals keyboard by default
* role="spinbutton" - number field is actually a spinner
* aria-valuenow - current value or 0
* aria-valuetext - current value or 0, need this to improve user-friendly and human-understandable when screen reader announce value
* @keydown - Listener for `keydown` event. Runs `this.onInputKeyDown`
* @beforeinput - Listener for `beforeinput` event. Runs `this.onBeforeInputChange`
* @returns template map
Expand All @@ -876,6 +877,7 @@ export class NumberField extends FormFieldElement {
inputmode: 'decimal',
role: 'spinbutton',
'aria-valuenow': `${this.value || 0}`,
'aria-valuetext': `${this.value || 0}`,
'@keydown': this.onInputKeyDown,
'@beforeinput': this.onBeforeInputChange
};
Expand Down

0 comments on commit 8e2a1e4

Please sign in to comment.