Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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": "Add utility function to help merge ARIA attributes.",
"type": "patch"
}
],
"packageName": "@uifabric/utilities",
"email": "jagore@microsoft.com"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"changes": [
{
"packageName": "office-ui-fabric-react",
"comment": "Prevent invalid empty ARIA values from being output.",
"type": "patch"
}
],
"packageName": "office-ui-fabric-react",
"email": "jagore@microsoft.com"
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,11 +419,11 @@ exports[`Breadcrumb basic rendering renders breadcumb correctly 2 1`] = `
}
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-expanded={false}
aria-haspopup={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-owns={null}
aria-pressed={undefined}
className=
Expand Down Expand Up @@ -1138,11 +1138,11 @@ exports[`Breadcrumb basic rendering renders breadcumb correctly 4 1`] = `
}
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-expanded={false}
aria-haspopup={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-owns={null}
aria-pressed={undefined}
className=
Expand Down Expand Up @@ -1505,11 +1505,11 @@ exports[`Breadcrumb basic rendering renders breadcumb correctly 5 1`] = `
}
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-expanded={false}
aria-haspopup={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-owns={null}
aria-pressed={undefined}
className=
Expand Down Expand Up @@ -1712,11 +1712,11 @@ exports[`Breadcrumb basic rendering renders breadcumb correctly 6 1`] = `
}
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-expanded={false}
aria-haspopup={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-owns={null}
aria-pressed={undefined}
className=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
getNativeProps,
KeyCodes,
createRef,
css
css,
mergeAriaAttributeValues
} from '../../Utilities';
import { Icon } from '../../Icon';
import { DirectionalHint } from '../../common/DirectionalHint';
Expand Down Expand Up @@ -142,29 +143,27 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
]);

// Check for ariaDescription, secondaryText or aria-describedby in the native props to determine source of aria-describedby
// otherwise default to null.
let ariaDescribedBy;
// otherwise default to undefined so property does not appear in output.
let ariaDescribedBy = undefined;
if (ariaDescription) {
ariaDescribedBy = _ariaDescriptionId;
} else if (secondaryText) {
ariaDescribedBy = _descriptionId;
} else if ((nativeProps as any)['aria-describedby']) {
ariaDescribedBy = (nativeProps as any)['aria-describedby'];
} else {
ariaDescribedBy = null;
}

// If an explicit ariaLabel is given, use that as the label and we're done.
// If an explicit aria-labelledby is given, use that and we're done.
// If any kind of description is given (which will end up as an aria-describedby attribute),
// set the labelledby element. Otherwise, the button is labeled implicitly by the descendent
// text on the button (if it exists). Never set both aria-label and aria-labelledby.
let ariaLabelledBy = null;
let ariaLabelledBy = undefined;
if (!ariaLabel) {
if ((nativeProps as any)['aria-labelledby']) {
ariaLabelledBy = (nativeProps as any)['aria-labelledby'];
} else if (ariaDescribedBy) {
ariaLabelledBy = text ? _labelId : null;
ariaLabelledBy = text ? _labelId : undefined;
}
}

Expand Down Expand Up @@ -514,7 +513,7 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
'data-is-focusable': false
}
);
const ariaDescribedBy = buttonProps.ariaDescription || '';
const ariaDescribedBy = buttonProps.ariaDescription;

if (keytipProps && menuProps) {
keytipProps = {
Expand All @@ -534,7 +533,7 @@ export class BaseButton extends BaseComponent<IBaseButtonProps, IBaseButtonState
aria-haspopup={ true }
aria-expanded={ this._isExpanded }
aria-pressed={ this.props.checked }
aria-describedby={ ariaDescribedBy + (keytipAttributes['aria-describedby'] || '') }
aria-describedby={ mergeAriaAttributeValues(ariaDescribedBy, keytipAttributes['aria-describedby']) }
className={ classNames && classNames.splitButtonContainer }
onKeyDown={ this._onSplitButtonContainerKeyDown }
onTouchStart={ this._onTouchStart }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

exports[`Button renders ActionButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -116,11 +116,11 @@ exports[`Button renders ActionButton correctly 1`] = `

exports[`Button renders CommandBarButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-expanded={false}
aria-haspopup={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-owns={null}
aria-pressed={undefined}
className=
Expand Down Expand Up @@ -293,7 +293,7 @@ exports[`Button renders CompoundButton correctly 1`] = `
<button
aria-describedby="id__14"
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -432,9 +432,9 @@ exports[`Button renders CompoundButton correctly 1`] = `

exports[`Button renders DefaultButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -543,9 +543,9 @@ exports[`Button renders DefaultButton correctly 1`] = `

exports[`Button renders IconButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label="Emoji"
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -659,7 +659,7 @@ exports[`Button renders a DefaultButton with a keytip correctly 1`] = `
<button
aria-describedby=" ktp-layer-id ktp-a"
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

exports[`Button renders ActionButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -116,11 +116,11 @@ exports[`Button renders ActionButton correctly 1`] = `

exports[`Button renders CommandBarButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-expanded={false}
aria-haspopup={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-owns={null}
aria-pressed={undefined}
className=
Expand Down Expand Up @@ -293,7 +293,7 @@ exports[`Button renders CompoundButton correctly 1`] = `
<button
aria-describedby="id__14"
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -432,9 +432,9 @@ exports[`Button renders CompoundButton correctly 1`] = `

exports[`Button renders DefaultButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -543,9 +543,9 @@ exports[`Button renders DefaultButton correctly 1`] = `

exports[`Button renders IconButton correctly 1`] = `
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label="Emoji"
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down Expand Up @@ -659,7 +659,7 @@ exports[`Button renders a DefaultButton with a keytip correctly 1`] = `
<button
aria-describedby=" ktp-layer-id ktp-a"
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={undefined}
className=
ms-Button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
getId,
createRef,
customizable,
classNamesFunction
classNamesFunction,
mergeAriaAttributeValues
} from '../../Utilities';
import { Icon } from '../../Icon';
import {
Expand Down Expand Up @@ -115,7 +116,7 @@ export class CheckboxBase extends BaseComponent<ICheckboxProps, ICheckboxState>
aria-disabled={ disabled }
aria-label={ ariaLabel }
aria-labelledby={ ariaLabelledBy }
aria-describedby={ (ariaDescribedBy || '') + (keytipAttributes['aria-describedby'] || '') }
aria-describedby={ mergeAriaAttributeValues(ariaDescribedBy, keytipAttributes['aria-describedby']) }
aria-posinset={ ariaPositionInSet }
aria-setsize={ ariaSetSize }
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ exports[`ComboBox Renders ComboBox correctly 1`] = `
value="testValue"
/>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-hidden={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={false}
checked={false}
className=
Expand Down Expand Up @@ -441,10 +441,10 @@ exports[`ComboBox renders a ComboBox with a Keytip correctly 1`] = `
value=""
/>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-hidden={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={false}
checked={false}
className=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,10 @@ exports[`ComboBox Renders ComboBox correctly 1`] = `
value="testValue"
/>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-hidden={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={false}
checked={false}
className=
Expand Down Expand Up @@ -440,10 +440,10 @@ exports[`ComboBox renders a ComboBox with a Keytip correctly 1`] = `
value=""
/>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-hidden={true}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-pressed={false}
checked={false}
className=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ exports[`CommandBar renders commands correctly 1`] = `
className="ms-OverflowSet-item"
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-posinset={1}
aria-pressed={undefined}
aria-setsize={2}
Expand Down Expand Up @@ -174,9 +174,9 @@ exports[`CommandBar renders commands correctly 1`] = `
className="ms-OverflowSet-item"
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-posinset={2}
aria-pressed={undefined}
aria-setsize={2}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ exports[`CommandBar renders commands correctly 1`] = `
className="ms-OverflowSet-item"
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-posinset={1}
aria-pressed={undefined}
aria-setsize={2}
Expand Down Expand Up @@ -173,9 +173,9 @@ exports[`CommandBar renders commands correctly 1`] = `
className="ms-OverflowSet-item"
>
<button
aria-describedby={null}
aria-describedby={undefined}
aria-label={undefined}
aria-labelledby={null}
aria-labelledby={undefined}
aria-posinset={2}
aria-pressed={undefined}
aria-setsize={2}
Expand Down
Loading