Skip to content

Commit

Permalink
fix(react-examples): Improved information for screen readers on Facep…
Browse files Browse the repository at this point in the history
…ile examples (#16479)

#### Pull request checklist

- [x] Addresses an existing issue: Fixes microsoftdesign/fluentui#10275
- [x] Include a change request file using `$ yarn change`: No change files are needed

#### Description of changes

Added Announced for the adding person action
Changed button label to improve clarity
  • Loading branch information
andrefcdias authored Jan 20, 2021
1 parent 0827183 commit d820d6e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as React from 'react';
import { Facepile, OverflowButtonType } from '@fluentui/react/lib/Facepile';
import { facepilePersonas } from '@fluentui/example-data';
import { Announced } from '@fluentui/react';

const overflowButtonProps = {
ariaLabel: 'More users',
Expand All @@ -14,21 +15,28 @@ export const FacepileAddFaceExample: React.FunctionComponent = () => {

const addButtonProps = React.useMemo(
() => ({
ariaLabel: 'Add a new person',
onClick: (ev: React.MouseEvent<HTMLButtonElement>) => setNumberOfFaces(numberOfFaces + 1),
ariaLabel: 'Add a new person to the Facepile',
onClick: (ev: React.MouseEvent<HTMLButtonElement>) => {
setNumberOfFaces(numberOfFaces + 1);
},
}),
[numberOfFaces],
);

return (
<Facepile
personas={personas}
maxDisplayablePersonas={5}
overflowButtonProps={overflowButtonProps}
overflowButtonType={OverflowButtonType.descriptive}
showAddButton
addButtonProps={addButtonProps}
ariaDescription="To move through the items use left and right arrow keys."
/>
<>
{numberOfFaces > 0 ? (
<Announced message={`New person added, currently ${numberOfFaces} in the Facepile.`} aria-live="assertive" />
) : null}
<Facepile
personas={personas}
maxDisplayablePersonas={5}
overflowButtonProps={overflowButtonProps}
overflowButtonType={OverflowButtonType.descriptive}
showAddButton
addButtonProps={addButtonProps}
ariaDescription="To move through the items use left and right arrow keys."
/>
</>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ exports[`Component Examples renders Facepile.AddFace.Example.tsx correctly 1`] =
}
>
<button
aria-label="Add a new person"
aria-label="Add a new person to the Facepile"
className=
ms-Button
ms-Facepile-addButton
Expand Down

0 comments on commit d820d6e

Please sign in to comment.