Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "@uifabric/utilities",
"comment": "ARIA: mergeAriaAttributeValues should produce space-delimited output by default",
"type": "patch"
}
],
"packageName": "@uifabric/utilities",
"email": "keco@microsoft.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "ARIA: Update calls to mergeAriaAttributeValues to no longer explicitly supply output element id padding.",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "keco@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ export class ComboBox extends BaseComponent<IComboBoxProps, IComboBoxState> {
readOnly={disabled || !allowFreeform}
aria-labelledby={label && id + '-label'}
aria-label={ariaLabel && !label ? ariaLabel : undefined}
aria-describedby={mergeAriaAttributeValues(ariaDescribedBy, ' ', keytipAttributes['aria-describedby'])}
aria-describedby={mergeAriaAttributeValues(ariaDescribedBy, keytipAttributes['aria-describedby'])}
aria-activedescendant={this._getAriaActiveDescentValue()}
aria-disabled={disabled}
aria-owns={isOpen ? id + '-list' : undefined}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export class SpinButton extends BaseComponent<ISpinButtonProps, ISpinButtonState
aria-valuetext={ariaValueText ? ariaValueText : isNaN(Number(value)) ? value : undefined}
aria-valuemin={min}
aria-valuemax={max}
aria-describedby={mergeAriaAttributeValues(ariaDescribedBy, ' ', keytipAttributes['aria-describedby'])}
aria-describedby={mergeAriaAttributeValues(ariaDescribedBy, keytipAttributes['aria-describedby'])}
onBlur={this._onBlur}
ref={this._input}
onFocus={this._onFocus}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ exports[`Component Examples renders Keytips.Button.Example.tsx correctly 1`] = `
</div>
</button>
<button
aria-describedby="id__4 ktp-layer-id ktp-1-b"
aria-describedby="id__4 ktp-layer-id ktp-1-b"
Comment thread
KevinTCoughlin marked this conversation as resolved.
aria-labelledby="id__3"
className=
ms-Button
Expand Down
4 changes: 2 additions & 2 deletions packages/utilities/src/aria.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('aria utils tests', () => {
cases: [
{
args: ['arg1', 'arg2'],
expected: 'arg1arg2'
expected: 'arg1 arg2'
},
{
args: ['arg1', undefined],
Expand All @@ -84,7 +84,7 @@ describe('aria utils tests', () => {
expected: 'arg1'
},
{
args: ['', 'arg1 ', 'arg2 '],
args: ['', 'arg1', 'arg2 '],
expected: 'arg1 arg2'
}
]
Expand Down
4 changes: 1 addition & 3 deletions packages/utilities/src/aria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
* ARIA helper to concatenate attributes, returning undefined if all attributes
* are undefined. (Empty strings are not a valid ARIA attribute value.)
*
* NOTE: This function will NOT insert whitespace between provided attributes.
*
* @param ariaAttributes - ARIA attributes to merge
*/
export function mergeAriaAttributeValues(...ariaAttributes: (string | undefined)[]): string | undefined {
const mergedAttribute = ariaAttributes
.filter((arg: string | undefined) => arg !== undefined && arg !== null)
.join('')
.join(' ')
.trim();
return mergedAttribute === '' ? undefined : mergedAttribute;
}