ARIA: Fix mergeAriaAttributeValues not producing space delimited ID reference lists#8066
ARIA: Fix mergeAriaAttributeValues not producing space delimited ID reference lists#8066KevinTCoughlin wants to merge 2 commits intomicrosoft:masterfrom
Conversation
|
Speaking with @JasonGore, the existing tests need to continue to pass without modification aside from producing space-delimited values We should also validate that padding the value with spaces is valid or if they should be trimmed. The input |
|
As long as inputs appending spaces continue to work as expected, then I consider this patch to be functionally compatible and a robustness improvement. However, the most important thing is that we never return empty strings or nulls, even when given empty strings and nulls as inputs. If there is no alphanumeric content, then |
| */ | ||
| export function mergeAriaAttributeValues(...ariaAttributes: (string | undefined)[]): string | undefined { | ||
| const mergedAttribute = ariaAttributes.filter((arg: string | undefined) => arg !== undefined && arg !== null).join(''); | ||
| const mergedAttribute = ariaAttributes.filter((arg: string | undefined) => arg !== undefined && arg !== null).join(' '); |
There was a problem hiding this comment.
Should we have .join(' ').trim() maybe?
Pull request checklist
$ npm run changeDescription of changes
The Problem
Reviewing #8057 brought to my attention that
mergeAriaAttributeValuesis producing invalid values foraria-describedbywhen it receives multiple input values. That is because it is concatenating the values without a space which screen reader technology does not understand.Repro
This Codepen illustrates the problem with Narrator enabled as you focus the two buttons. One of the buttons has its
aria-describedbyvalue space-delimited while the other does not. Narrator only reads the space-delimited values.Narrator Output
MDN states that
aria-describedbyand similar attributes must have the value of:This "space-separated list of element IDs" is referred to as a "ID reference list" in the W3 ARIA spec.
How to resolve
Currently,
mergeAriaAttributeValuesusage is confined toaria-describedbyin a handful of call sites within OUFR. However, it is also publicly exported as part of the API surface.@JasonGore, I'm happy to patch this, but need your opinion from an API standpoint before proceeding. The options I see are:
mergeAriaAttributeValuesas done in this PR currently to space delimit the values. This makes sense to me if there aren't any valid ARIA use-cases for concatenated values without the space.OR
''or' '. And perhaps offer a wrapper function for thearia-describedbyuse-case.Focus areas to test
I'm going to let the tests fail while we discuss correct behavior here.
Microsoft Reviewers: Open in CodeFlow