Skip to content

fix(#4160): NumberField: screen reader fails to announce negative values with currencySign: 'accounting' #4161

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

Conversation

majornista
Copy link
Collaborator

@majornista majornista commented Mar 3, 2023

Closes #4160

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

  1. Open https://reactspectrum.blob.core.windows.net/reactspectrum/3e5388ac6912b0f3bff0811f6196dd7bfdb58ad1/storybook/index.html?path=/story/numberfield--currency-switcher&providerSwitcher-express=false
  2. Select Currency Sign: Accounting from the dropdown
  3. With a screen reader running, decrement the NumberInput until negative accounting values are reached.
  4. Screen reader should announce "negative" or "minus" before negative accounting value.

🧢 Your Project:

Adobe/Accessibility

@rspbot
Copy link

rspbot commented Mar 3, 2023

@rspbot
Copy link

rspbot commented Mar 4, 2023

@rspbot
Copy link

rspbot commented Mar 6, 2023

@rspbot
Copy link

rspbot commented Mar 6, 2023

…unce-negative-values-with-currencysign-accounting
@rspbot
Copy link

rspbot commented Mar 6, 2023

// Replace negative value formatted using currencySign: 'accounting'
// with a value that can be announced using a minus sign.
.replace(/^\((.+)\)$/, '\u2212$1');
textValue = textValue === '' ? stringFormatter.format('Empty') : (textValue || `${value}`).replace('-', '\u2212');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be moved up to useNumberField, because then we can grab the minusSign character and out of formatToParts

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the problem was that it is coming from the number formatter, but the screen reader doesn't announce that character right.

Copy link
Member

@snowystinger snowystinger Mar 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, but there may be other minus sign symbols, if we moved it up, we could always replace whatever symbol with the one that we know the screen reader can announce?
if I recall correctly, there's like 3 of them at least

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't useSpinButton handle announcement of the minus sign and "Empty" at this lower level? I can understand moving the currency formatting up, the useNumberField, because that's where we accept formatOptions, but it seems to make sense to keep the logic to announce 'minus' here. Are you saying there are three Unicode symbols for the minus sign that screen readers can announce, or three locales that use different symbols for the minus sign, that might have to be replaced with a more robust regex?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are around 3 different locale specific minus signs, if I recall correctly.
But now I feel like I'm expanding the scope of this.
So let's keep useSpinButton as it was, and handle the currency negative up in useNumberField as you were doing.

…unce-negative-values-with-currencysign-accounting
@rspbot
Copy link

rspbot commented Mar 8, 2023

@rspbot
Copy link

rspbot commented Mar 8, 2023

## API Changes

unknown top level export { type: 'identifier', name: 'Column' }
unknown top level export { type: 'identifier', name: 'Column' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }
unknown type { type: 'link' }

@snowystinger snowystinger merged commit d6adfeb into main Mar 8, 2023
@snowystinger snowystinger deleted the 4160-numberfield-screen-reader-fails-to-announce-negative-values-with-currencysign-accounting branch March 8, 2023 17:05
@snowystinger snowystinger mentioned this pull request Mar 18, 2023
5 tasks
@devongovett
Copy link
Member

@majornista in testing we noticed a couple issues:

  1. NVDA reads e.g. "3 euros, minus 3 euros". I assume it is reading the actual input value (in accounting notation) plus our custom announcement.
  2. Talkback announces negative accounting values as "minus Euro 2"

I noticed in the number field code we override the spin button role and all of the associated attributes to work around a VoiceOver issue (according to the comment):

// override the spinbutton role, we can't focus a spin button with VO
role: null,
// ignore aria-roledescription on iOS so that required state will announce when it is present
'aria-roledescription': (!isIOS() ? stringFormatter.format('numberField') : null),
'aria-valuemax': null,
'aria-valuemin': null,
'aria-valuenow': null,
'aria-valuetext': null,

Maybe we should make this happen only on Apple platforms so that NVDA treats this as a spin button and announces the aria-valuetext (which should be set to the non-accounting notation) rather than the input value?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NumberField: screen reader fails to announce negative values with currencySign: 'accounting'
4 participants