Skip to content

Commit

Permalink
feat(a11y): require Tree aria-label or aria-labelledby
Browse files Browse the repository at this point in the history
  • Loading branch information
lismith2-cisco committed Jan 9, 2025
1 parent 6f15516 commit 33b8244
Show file tree
Hide file tree
Showing 12 changed files with 227 additions and 98 deletions.
6 changes: 5 additions & 1 deletion src/components/SpaceTreeNode/SpaceTreeNode.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export default {
};

const TreeWrapper = (Story) => (
<Tree excludeTreeRoot={false} treeStructure={createTreeNode('root', true, [])}>
<Tree
excludeTreeRoot={false}
treeStructure={createTreeNode('root', true, [])}
aria-label="some tree"
>
<Story />
</Tree>
);
Expand Down
6 changes: 5 additions & 1 deletion src/components/SpaceTreeNode/SpaceTreeNode.unit.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import Tree from '../Tree';
describe('<SpaceTreeNode />', () => {
const mount = async (component) => {
return mountAndWait(
<Tree excludeTreeRoot={false} treeStructure={createTreeNode('root', true, [])}>
<Tree
excludeTreeRoot={false}
treeStructure={createTreeNode('root', true, [])}
aria-label="some tree"
>
{component}
</Tree>
);
Expand Down
40 changes: 40 additions & 0 deletions src/components/SpaceTreeNode/SpaceTreeNode.unit.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

exports[`<SpaceTreeNode /> snapshot checks divider dot position in compact mode 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -12,6 +13,7 @@ exports[`<SpaceTreeNode /> snapshot checks divider dot position in compact mode
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -185,6 +187,7 @@ exports[`<SpaceTreeNode /> snapshot checks divider dot position in compact mode

exports[`<SpaceTreeNode /> snapshot should match snapshot 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -195,6 +198,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -311,6 +315,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with action 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -321,6 +326,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with action 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -451,6 +457,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with action 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with className 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -461,6 +468,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with className 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -578,6 +586,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with className 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with firstLine 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -588,6 +597,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with firstLine 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -708,6 +718,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with firstLine 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with id 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -718,6 +729,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with id 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -836,6 +848,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with id 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with isAlert 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -846,6 +859,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isAlert 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -995,6 +1009,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isAlert 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with isAlertMuted 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1005,6 +1020,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isAlertMuted 1`]
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -1154,6 +1170,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isAlertMuted 1`]

exports[`<SpaceTreeNode /> snapshot should match snapshot with isDisabled 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1164,6 +1181,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isDisabled 1`] =
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -1281,6 +1299,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isDisabled 1`] =

exports[`<SpaceTreeNode /> snapshot should match snapshot with isEnterRoom 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1291,6 +1310,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isEnterRoom 1`] =
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -1440,6 +1460,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isEnterRoom 1`] =

exports[`<SpaceTreeNode /> snapshot should match snapshot with isError 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1450,6 +1471,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isError 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -1599,6 +1621,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isError 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with isMention 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1609,6 +1632,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isMention 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -1758,6 +1782,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isMention 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with isNewActivity 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1768,6 +1793,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isNewActivity 1`]
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -1886,6 +1912,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isNewActivity 1`]

exports[`<SpaceTreeNode /> snapshot should match snapshot with isSelected 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -1896,6 +1923,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isSelected 1`] =
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -2014,6 +2042,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isSelected 1`] =

exports[`<SpaceTreeNode /> snapshot should match snapshot with isSelected and draft 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -2024,6 +2053,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isSelected and dr
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -2175,6 +2205,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isSelected and dr

exports[`<SpaceTreeNode /> snapshot should match snapshot with isUnread 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -2185,6 +2216,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isUnread 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -2334,6 +2366,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with isUnread 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with multiple string secondLine 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -2344,6 +2377,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with multiple string s
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -2543,6 +2577,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with multiple string s

exports[`<SpaceTreeNode /> snapshot should match snapshot with secondLine 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -2553,6 +2588,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with secondLine 1`] =
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -2714,6 +2750,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with secondLine 1`] =

exports[`<SpaceTreeNode /> snapshot should match snapshot with style 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -2724,6 +2761,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with style 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down Expand Up @@ -2855,6 +2893,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with style 1`] = `

exports[`<SpaceTreeNode /> snapshot should match snapshot with teamColor 1`] = `
<Tree
aria-label="some tree"
excludeTreeRoot={false}
treeStructure={
Object {
Expand All @@ -2865,6 +2904,7 @@ exports[`<SpaceTreeNode /> snapshot should match snapshot with teamColor 1`] = `
}
>
<div
aria-label="some tree"
className="md-tree-wrapper"
onBlur={[Function]}
onFocus={[Function]}
Expand Down
4 changes: 4 additions & 0 deletions src/components/Tree/Tree.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ Example.args = {
children: mapTree(exampleTreeMap, (node) => (
<ExampleTreeNode key={node.id.toString()} node={node} />
)),
'aria-label': 'some tree',
};

const WithRoot = Template<ComponentProps<typeof Tree>>(Tree).bind({});
Expand All @@ -137,6 +138,7 @@ WithRoot.args = {
(node) => <ExampleTreeNode key={node.id.toString()} node={node} />,
{ excludeRootNode: false }
),
'aria-label': 'some tree',
};
const TreeWithScroll = Template<ComponentProps<typeof Tree>>(Tree).bind({});

Expand All @@ -153,6 +155,7 @@ TreeWithScroll.args = {
(node) => <ExampleTreeNode key={node.id.toString()} node={node} />,
{ excludeRootNode: false }
),
'aria-label': 'some tree',
};

const DynamicTree = Template(() => {
Expand Down Expand Up @@ -180,6 +183,7 @@ const DynamicTree = Template(() => {
isRenderedFlat={true}
shouldNodeFocusBeInset={true}
excludeTreeRoot={true}
aria-label="some tree"
>
{mapTree(
mappedTree,
Expand Down
Loading

0 comments on commit 33b8244

Please sign in to comment.