@workday/canvas-kit-mcp 16.0.14 → 16.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/dist/apps/checkbox.html +296 -211
- package/dist/apps/table.html +275 -133
- package/dist/cli.js +93 -13
- package/dist/cli.js.map +2 -2
- package/dist/index.js +93 -13
- package/dist/index.js.map +2 -2
- package/dist/lib/accessibility/Popups.mdx +1 -5
- package/dist/lib/accessibility/tables/ExpandableRows.mdx +29 -0
- package/dist/lib/accessibility/tables/FilterableColumnHeaders.mdx +39 -0
- package/dist/lib/accessibility/tables/NestedRows.mdx +41 -0
- package/dist/lib/accessibility/tables/Overview.mdx +32 -0
- package/dist/lib/accessibility/tables/SelectableRows.mdx +30 -0
- package/dist/lib/accessibility/tables/SortableColumnHeaders.mdx +25 -0
- package/dist/lib/accessibility/{TestingTableWithFormFields.mdx → tables/WithFormFields.mdx} +3 -2
- package/dist/types/lib/accessibility-enums.d.ts +3 -1
- package/dist/types/lib/accessibility-enums.d.ts.map +1 -1
- package/dist/types/lib/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/dist/lib/accessibility/TablesAdvanced.mdx +0 -128
|
@@ -47,10 +47,6 @@ hooks. **Tradeoff:** the popup is constrained by ancestor `overflow` and positio
|
|
|
47
47
|
|
|
48
48
|
<ExampleCodeBlock code={InlinePopupNoPortal} />
|
|
49
49
|
|
|
50
|
-
For the same reading-order goal using a **portaled** popup mounted into a sentinel next to the
|
|
51
|
-
trigger (with `PopupStack.pushStackContext`), see
|
|
52
|
-
[**Testing > Inline Portals**](?path=/docs/guides-accessibility-testing-inline-portals--docs).
|
|
53
|
-
|
|
54
50
|
## 2. Reading order with `aria-owns`
|
|
55
51
|
|
|
56
52
|
You can keep the default portal (content at the bottom of `body`) and still try to **re-parent** the
|
|
@@ -70,6 +66,6 @@ that card as “owned” by the trigger for browsing and announcements.
|
|
|
70
66
|
The Canvas Kit [**Dialog**](?path=/docs/components-popups-dialog--docs) builds this pattern in.
|
|
71
67
|
|
|
72
68
|
Another `aria-owns` example:
|
|
73
|
-
[
|
|
69
|
+
[Table Patterns > Filterable Column Headers](?path=/docs/guides-accessibility-table-patterns-filterable-column-headers--docs).
|
|
74
70
|
|
|
75
71
|
<ExampleCodeBlock code={PopupAriaOwns} />
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {Meta} from '@storybook/blocks';
|
|
2
|
+
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
3
|
+
|
|
4
|
+
import {ExpandableRows} from '../examples/Table/WithExpandableRows';
|
|
5
|
+
|
|
6
|
+
<Meta title="Guides/Accessibility/Table Patterns/Expandable Rows" />
|
|
7
|
+
|
|
8
|
+
## Expandable Rows
|
|
9
|
+
|
|
10
|
+
Expandable Rows combines the likes of an accordion with tabular data tables. Column 1 renders icon
|
|
11
|
+
buttons with 2 states, a collapsed and expanded state. A new row that spans the entire width of the
|
|
12
|
+
table is added to the table just after the expanded row.
|
|
13
|
+
|
|
14
|
+
- The `aria-expanded` property is added to the chevron button to communicate this state to screen
|
|
15
|
+
reader users.
|
|
16
|
+
- A Canvas accessible `Tooltip` component is used to assign names to each icon button based on the
|
|
17
|
+
most useful value in the row. In this example, we combined the car make (in column 1) and model
|
|
18
|
+
(in column 2) together. This allows everyone to view the name of the icon buttons by hovering the
|
|
19
|
+
mouse or focusing with the keyboard.
|
|
20
|
+
- The expanded row uses `colspan` to span the entire width of the table and support screen readers.
|
|
21
|
+
This space provides flexibility to show headings, lists, and other structured content for the
|
|
22
|
+
table row above.
|
|
23
|
+
- There is no explicit relationship between a row of cells and the spanned content below it. The
|
|
24
|
+
spanned content is assumed to belong to the row of cells above it, based on established accordion
|
|
25
|
+
patterns and logical reading order of content rendered to the screen.
|
|
26
|
+
- Outlining hierarchy with additional nested rows in the table is not supported for screen readers
|
|
27
|
+
in this example.
|
|
28
|
+
|
|
29
|
+
<ExampleCodeBlock code={ExpandableRows} />
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {Meta} from '@storybook/blocks';
|
|
2
|
+
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
3
|
+
|
|
4
|
+
import {FilterableColumnHeaders} from '../examples/Table/WithColumnHeaderFilters';
|
|
5
|
+
|
|
6
|
+
<Meta title="Guides/Accessibility/Table Patterns/Filterable Column Headers" />
|
|
7
|
+
|
|
8
|
+
## Filterable Column Headers
|
|
9
|
+
|
|
10
|
+
In this example, we demonstrate using the `Popup` component in each column header allowing users to
|
|
11
|
+
search and filter the data on the table. The `Popup` component relies on React Portals to render the
|
|
12
|
+
popup elements at the bottom of the browser's DOM presenting 2 key challenges for accessibility:
|
|
13
|
+
|
|
14
|
+
1. Keyboard focus order of the elements in the popup,
|
|
15
|
+
2. Screen readers' reading order of the content rendered in the browser.
|
|
16
|
+
|
|
17
|
+
Here's what we did about it:
|
|
18
|
+
|
|
19
|
+
- Canvas Kit includes a `usePopupModel` hook, with quite a few additional hooks developers can add
|
|
20
|
+
to their models. In particular, the `useFocusRedirect` hook manages keyboard focus between the
|
|
21
|
+
`<Popup.Target>` button and the popup content.
|
|
22
|
+
- The `useInitialFocus` hook allows developers to specify which element receives keyboard focus when
|
|
23
|
+
the popup appears. In this example, we auto-focused the search input field.
|
|
24
|
+
- To address the reading order of content, we set the `aria-owns` property onto the parent
|
|
25
|
+
`<Table.Header>` component (`<th>` DOM element) with 2 unique `id` values. The first `id` refers
|
|
26
|
+
to the `<Popup.Target>` button and the second refers to the `<Popup.Card>` container element. This
|
|
27
|
+
manually reassigns the column header's `<Popup.Target>` button and the `Popup` contents as
|
|
28
|
+
siblings in the browser's accessibility tree hierarchy. Screen readers **should** read the column
|
|
29
|
+
header buttons and the popup content in sequential order even though they are not siblings in the
|
|
30
|
+
DOM.
|
|
31
|
+
- The `type='description'` variant of the Canvas `Tooltip` is used to communicate the filtered state
|
|
32
|
+
of the column header, and assigned to the accessible description of the column header
|
|
33
|
+
`<TertiaryButton>` component.
|
|
34
|
+
- The `AriaLiveRegion` component is used to render the "X of Y items" status inside the table
|
|
35
|
+
caption. This enables screen readers to automatically describe the filter state changes of the
|
|
36
|
+
table content to users in real time. We recommend validating whether this use of a live region is
|
|
37
|
+
well supported for your screen reader and browser combinations first.
|
|
38
|
+
|
|
39
|
+
<ExampleCodeBlock code={FilterableColumnHeaders} />
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import {Meta} from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
4
|
+
|
|
5
|
+
import {NestedRows} from '../examples/Table/WithNestedRows';
|
|
6
|
+
|
|
7
|
+
<Meta title="Guides/Accessibility/Table Patterns/Nested Rows" />
|
|
8
|
+
|
|
9
|
+
## Nested Rows
|
|
10
|
+
|
|
11
|
+
Nested Rows shows a hierarchy of related records in **one table**, using additional `<tr>` elements
|
|
12
|
+
for child rows. Expanding a project reveals its phases; expanding a phase reveals its tasks. The
|
|
13
|
+
chevron and name share the Name cell so they indent together. Collapsing a parent hides its
|
|
14
|
+
descendants even if a child was previously expanded.
|
|
15
|
+
|
|
16
|
+
This is a different pattern from
|
|
17
|
+
[Expandable Rows](?path=/docs/guides-accessibility-table-patterns-expandable-rows--docs). That
|
|
18
|
+
example inserts a `colspan` panel with extra content for a single parent row. It does **not** add
|
|
19
|
+
nested table rows. Use Nested Rows when the children are themselves tabular records (same columns at
|
|
20
|
+
every level). Use Expandable Rows when the extra content is not a row of the same table.
|
|
21
|
+
|
|
22
|
+
- Child rows are siblings in the same `<tbody>`, not a nested `<table>` and not extra `<tbody>`
|
|
23
|
+
elements used to fake a tree.
|
|
24
|
+
- The Name cell is the tree column: it holds the chevron `TertiaryButton` and the row name together
|
|
25
|
+
so the control stays next to the label it expands. Leaf rows keep an empty slot the same width as
|
|
26
|
+
the button so names line up with their siblings.
|
|
27
|
+
- The `aria-expanded` property is added to the chevron button to communicate this state to screen
|
|
28
|
+
reader users.
|
|
29
|
+
- A Canvas Kit `Tooltip` names each chevron **Project**, **Phase**, or **Task** based on the row's
|
|
30
|
+
depth. The visible name stays in the row header, so the button name describes the _kind_ of row
|
|
31
|
+
rather than repeating the label.
|
|
32
|
+
- Since those button names are not unique, we added `aria-describedby` to each chevron, referencing
|
|
33
|
+
the unique `id` on the name text in the same cell. That gives screen readers the specific project
|
|
34
|
+
or phase the control belongs to, similar to the
|
|
35
|
+
[Selectable Rows](?path=/docs/guides-accessibility-table-patterns-selectable-rows--docs)
|
|
36
|
+
checkboxes.
|
|
37
|
+
- `aria-level` is set on each `Table.Row` (`1` = project, `2` = phase, `3` = task) to describe
|
|
38
|
+
depth. Support for `aria-level` on HTML table rows is uneven across screen readers and browsers.
|
|
39
|
+
Validate the combinations you support. This is a research example, not a Canvas Kit primitive.
|
|
40
|
+
|
|
41
|
+
<ExampleCodeBlock code={NestedRows} />
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {Meta} from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
<Meta title="Guides/Accessibility/Table Patterns" />
|
|
4
|
+
|
|
5
|
+
## Advanced Table Examples
|
|
6
|
+
|
|
7
|
+
Tables should only be used to organize data that has a clear relationship between rows and columns,
|
|
8
|
+
like a calendar or a schedule. Never use a table just for page layout.
|
|
9
|
+
|
|
10
|
+
When you use the proper HTML table markup, a screen reader can help a user navigate the table. It
|
|
11
|
+
will automatically read the column and row headers as they move through the data, so they always
|
|
12
|
+
know what information they're looking at.
|
|
13
|
+
|
|
14
|
+
- All tables should have a clear header and a descriptive title.
|
|
15
|
+
- Keep your tables simple. If a table is too complex, it might be better to break it up into several
|
|
16
|
+
smaller tables or use a different format.
|
|
17
|
+
|
|
18
|
+
Out of the box, `Table` is a lightweight compound component with a high degree of flexibility, but
|
|
19
|
+
not much functionality outside of providing a basic table layout. This flexibility lets developers
|
|
20
|
+
implement common features, such as selecting rows and sorting columns, on top of `Table` to meet
|
|
21
|
+
their specific application needs.
|
|
22
|
+
|
|
23
|
+
The Workday Accessibility Team has researched and developed the following examples to demonstrate
|
|
24
|
+
how to build these accessible table patterns. We've listed the specific considerations and decisions
|
|
25
|
+
we've made for each of the examples.
|
|
26
|
+
|
|
27
|
+
- [Expandable Rows](?path=/docs/guides-accessibility-table-patterns-expandable-rows--docs)
|
|
28
|
+
- [Nested Rows](?path=/docs/guides-accessibility-table-patterns-nested-rows--docs)
|
|
29
|
+
- [Selectable Rows](?path=/docs/guides-accessibility-table-patterns-selectable-rows--docs)
|
|
30
|
+
- [Filterable Column Headers](?path=/docs/guides-accessibility-table-patterns-filterable-column-headers--docs)
|
|
31
|
+
- [Sortable Column Headers](?path=/docs/guides-accessibility-table-patterns-sortable-column-headers--docs)
|
|
32
|
+
- [With Form Fields](?path=/docs/guides-accessibility-table-patterns-with-form-fields--docs)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {Meta} from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
4
|
+
|
|
5
|
+
import {SelectableRows} from '../examples/Table/WithSelectableRows';
|
|
6
|
+
|
|
7
|
+
<Meta title="Guides/Accessibility/Table Patterns/Selectable Rows" />
|
|
8
|
+
|
|
9
|
+
## Selectable Rows
|
|
10
|
+
|
|
11
|
+
Using a `Checkbox` labeled "Select All" inside of a column header can be a confusing experience for
|
|
12
|
+
screen reader users. Screen readers will automatically announce the "Select All" label in the column
|
|
13
|
+
header each time users are reading any of the Check boxes in the first column. For instance, the
|
|
14
|
+
`Checkbox` in row 4 is definitely not going to select all of the rows. Here is what we did about it:
|
|
15
|
+
|
|
16
|
+
- We intentionally rendered row 1, column 1 as a standard `<td>` element so screen readers won't
|
|
17
|
+
automatically announce the "Select All" label while reading cells in column 1.
|
|
18
|
+
- Our research found that VoiceOver (MacOS v12.7, Safari v17.1) persistently announce "Select All"
|
|
19
|
+
despite using the `<td>` element because of the optional `<thead>` element in the table. We
|
|
20
|
+
omitted the optional `<thead>` and `<tbody>` elements from this example for that reason.
|
|
21
|
+
- We used Canvas Kit's `Tooltip` component to assign concise names to each Checkbox, describing
|
|
22
|
+
their purpose of selecting rows. This allows everyone to view the name of the checkboxes by
|
|
23
|
+
hovering the mouse or focusing with the keyboard.
|
|
24
|
+
- Since each checkbox is not uniquely labeled, we added `aria-describedby` to the checkbox,
|
|
25
|
+
referencing the unique `id` of the row header cell. This practice gives screen readers more
|
|
26
|
+
context about which value each checkbox is refering to.
|
|
27
|
+
- We rendered the cells in column 2 as the row headers for the table, enabling screen readers to
|
|
28
|
+
automatically announce the topping name even while reading down the Amounts in column 3.
|
|
29
|
+
|
|
30
|
+
<ExampleCodeBlock code={SelectableRows} />
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import {Meta} from '@storybook/blocks';
|
|
2
|
+
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
3
|
+
|
|
4
|
+
import {SortableColumnHeaders} from '../examples/Table/WithSortableColumnHeaders';
|
|
5
|
+
|
|
6
|
+
<Meta title="Guides/Accessibility/Table Patterns/Sortable Column Headers" />
|
|
7
|
+
|
|
8
|
+
## Sortable Column Headers
|
|
9
|
+
|
|
10
|
+
The challenge in this example is to provide all of the necessary information about the interactive
|
|
11
|
+
column headers, the sort state of the column, and instructions about how the table will be sorted
|
|
12
|
+
without giving too much information to users while reading the data cells below.
|
|
13
|
+
|
|
14
|
+
- The `aria-sort` property has been added to each of the `<Table.Header>` components (`<th>` DOM
|
|
15
|
+
element) and updated to `ascending` or `descending` to reflect the current sort state. We
|
|
16
|
+
recommend validating whether this property is well supported for your screen reader and browser
|
|
17
|
+
combinations first.
|
|
18
|
+
- A `<TertiaryButton>` describing the column name is used inside of the `<Table.Header>` component.
|
|
19
|
+
- The `description` variant of the Canvas `Tooltip` component is applied to the button in the column
|
|
20
|
+
header and applied to the accessible description of the button with the `aria-description`
|
|
21
|
+
property. This is used to describe how the column will be sorted when pressed and screen readers
|
|
22
|
+
will only read this description while focusing on the column headers, not while reading the data
|
|
23
|
+
cells below.
|
|
24
|
+
|
|
25
|
+
<ExampleCodeBlock code={SortableColumnHeaders} />
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {Meta} from '@storybook/blocks';
|
|
2
2
|
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
3
|
-
import {WithFormFields} from './examples/Table/WithFormFields';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import {WithFormFields} from '../examples/Table/WithFormFields';
|
|
5
|
+
|
|
6
|
+
<Meta title="Guides/Accessibility/Table Patterns/With Form Fields" />
|
|
6
7
|
|
|
7
8
|
## Table with form field components
|
|
8
9
|
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export declare const ACCESSIBILITY_SCENARIOS: readonly ["overview", "page-structure", "tables", "popups", "aria-live", "headers", "side-panel", "windows-high-contrast", "forms", "color-contrast"];
|
|
1
|
+
export declare const ACCESSIBILITY_SCENARIOS: readonly ["overview", "page-structure", "tables", "expandable-rows", "nested-rows", "selectable-rows", "filterable-column-headers", "sortable-column-headers", "popups", "aria-live", "headers", "side-panel", "windows-high-contrast", "forms", "color-contrast"];
|
|
2
2
|
export type AccessibilityScenario = (typeof ACCESSIBILITY_SCENARIOS)[number];
|
|
3
|
+
/** Pattern pages under Guides/Accessibility/Table Patterns, including the overview index. */
|
|
4
|
+
export declare const TABLE_PATTERN_SCENARIOS: readonly AccessibilityScenario[];
|
|
3
5
|
export declare const ACCESSIBILITY_COMPONENTS: readonly ["action-bar", "ai-ingress-button-(ai)", "avatar", "banner", "body-text", "box", "breadcrumbs", "buttons", "card", "checkbox", "color-input", "color-picker", "color-preview", "countbadge", "dialog", "divider", "expandable", "flex", "form-field", "grid", "heading", "hyperlink", "information-highlight", "loading-dots", "loading-sparkles-(ai)", "menu", "modal", "multi-select", "pagination", "pill", "popper", "popup", "radio", "radio-(deprecated)", "segmented-control", "select", "side-panel-(deprecated)", "side-panel", "skeleton", "status-indicator", "status-indicator-(deprecated)", "subtext", "switch-(new)", "switch-(deprecated)", "table", "tabs", "text", "text-area", "text-input", "title", "toast", "toolbar", "tooltip"];
|
|
4
6
|
export type AccessibilityComponent = (typeof ACCESSIBILITY_COMPONENTS)[number];
|
|
5
7
|
export declare function getAccessibilityScenarioSlugsForComponent(component: string): AccessibilityScenario[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accessibility-enums.d.ts","sourceRoot":"","sources":["../../../lib/accessibility-enums.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"accessibility-enums.d.ts","sourceRoot":"","sources":["../../../lib/accessibility-enums.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,uBAAuB,oQAgB1B,CAAC;AAEX,MAAM,MAAM,qBAAqB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7E,6FAA6F;AAC7F,eAAO,MAAM,uBAAuB,EAAE,SAAS,qBAAqB,EAQnE,CAAC;AAwBF,eAAO,MAAM,wBAAwB,kuBAsD3B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,wBAAwB,CAAC,CAAC,MAAM,CAAC,CAAC;AA0D/E,wBAAgB,yCAAyC,CACvD,SAAS,EAAE,MAAM,GAChB,qBAAqB,EAAE,CAsBzB;AAED,wBAAgB,iCAAiC,CAAC,EAChD,SAAS,EACT,QAAQ,GACT,EAAE;IACD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,qBAAqB,CAAC;CAClC,GAAG,qBAAqB,EAAE,CAiB1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAC;AAkBlE,wBAAgB,SAAS,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../lib/index.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAC;AAkBlE,wBAAgB,SAAS,cA4jCxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-mcp",
|
|
3
|
-
"version": "16.0.
|
|
3
|
+
"version": "16.0.16",
|
|
4
4
|
"description": "MCP package for Canvas Kit",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"vite": "^5.0.0",
|
|
64
64
|
"vite-plugin-singlefile": "^2.0.0"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "ecd8756a79137742567e511e64bb7f1fa14f659c"
|
|
67
67
|
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {Meta} from '@storybook/blocks';
|
|
2
|
-
import {ExampleCodeBlock} from '@workday/canvas-kit-docs';
|
|
3
|
-
|
|
4
|
-
import {SelectableRows} from './examples/Table/WithSelectableRows';
|
|
5
|
-
import {ExpandableRows} from './examples/Table/WithExpandableRows';
|
|
6
|
-
import {SortableColumnHeaders} from './examples/Table/WithSortableColumnHeaders';
|
|
7
|
-
import {FilterableColumnHeaders} from './examples/Table/WithColumnHeaderFilters';
|
|
8
|
-
|
|
9
|
-
<Meta title="Guides/Accessibility/Examples/Advanced Tables" />
|
|
10
|
-
|
|
11
|
-
## Advanced Table Examples
|
|
12
|
-
|
|
13
|
-
Tables should only be used to organize data that has a clear relationship between rows and columns,
|
|
14
|
-
like a calendar or a schedule. Never use a table just for page layout.
|
|
15
|
-
|
|
16
|
-
When you use the proper HTML table markup, a screen reader can help a user navigate the table. It
|
|
17
|
-
will automatically read the column and row headers as they move through the data, so they always
|
|
18
|
-
know what information they're looking at.
|
|
19
|
-
|
|
20
|
-
- All tables should have a clear header and a descriptive title.
|
|
21
|
-
- Keep your tables simple. If a table is too complex, it might be better to break it up into several
|
|
22
|
-
smaller tables or use a different format.
|
|
23
|
-
|
|
24
|
-
Out of the box, `Table` is a lightweight compound component with a high degree of flexibility, but
|
|
25
|
-
not much functionality outside of providing a basic table layout. This flexibility lets developers
|
|
26
|
-
implement common features, such as selecting rows and sorting columns, on top of `Table` to meet
|
|
27
|
-
their specific application needs.
|
|
28
|
-
|
|
29
|
-
The Workday Accessibility Team has researched and developed the following examples below to
|
|
30
|
-
demonstrate how to build these accessible table patterns. We've listed the specific considerations
|
|
31
|
-
and decisions we've made for each of the examples.
|
|
32
|
-
|
|
33
|
-
### Expandable Rows
|
|
34
|
-
|
|
35
|
-
Expandable Rows combines the likes of an accordion with tabular data tables. Column 1 renders icon
|
|
36
|
-
buttons with 2 states, a collapsed and expanded state. A new row that spans the entire width of the
|
|
37
|
-
table is added to the table just after the expanded row.
|
|
38
|
-
|
|
39
|
-
- The `aria-expanded` property is added to the chevron button to communicate this state to screen
|
|
40
|
-
reader users.
|
|
41
|
-
- A Canvas accessible `Tooltip` component is used to assign names to each icon button based on the
|
|
42
|
-
most useful value in the row. In this example, we combined the car make (in column 1) and model
|
|
43
|
-
(in column 2) together. This allows everyone to view the name of the icon buttons by hovering the
|
|
44
|
-
mouse or focusing with the keyboard.
|
|
45
|
-
- The expanded row uses `colspan` to span the entire width of the table and support screen readers.
|
|
46
|
-
This space provides flexibility to show headings, lists, and other structured content for the
|
|
47
|
-
table row above.
|
|
48
|
-
- There is no explicit relationship between a row of cells and the spanned content below it. The
|
|
49
|
-
spanned content is assumed to belong to the row of cells above it, based on established accordion
|
|
50
|
-
patterns and logical reading order of content rendered to the screen.
|
|
51
|
-
- Outlining hierarchy with additional nested rows in the table is not supported for screen readers
|
|
52
|
-
in this example.
|
|
53
|
-
|
|
54
|
-
<ExampleCodeBlock code={ExpandableRows} />
|
|
55
|
-
|
|
56
|
-
### Selectable Rows
|
|
57
|
-
|
|
58
|
-
Using a `Checkbox` labeled "Select All" inside of a column header can be a confusing experience for
|
|
59
|
-
screen reader users. Screen readers will automatically announce the "Select All" label in the column
|
|
60
|
-
header each time users are reading any of the Check boxes in the first column. For instance, the
|
|
61
|
-
`Checkbox` in row 4 is definitely not going to select all of the rows. Here is what we did about it:
|
|
62
|
-
|
|
63
|
-
- We intentionally rendered row 1, column 1 as a standard `<td>` element so screen readers won't
|
|
64
|
-
automatically announce the "Select All" label while reading cells in column 1.
|
|
65
|
-
- Our research found that VoiceOver (MacOS v12.7, Safari v17.1) persistently announce "Select All"
|
|
66
|
-
despite using the `<td>` element because of the optional `<thead>` element in the table. We
|
|
67
|
-
omitted the optional `<thead>` and `<tbody>` elements from this example for that reason.
|
|
68
|
-
- We used Canvas' accessible `Tooltip` component to assign names to each Checkbox based on the most
|
|
69
|
-
useful value in the row, the topping name. This allows everyone to view the name of the checkboxes
|
|
70
|
-
by hovering the mouse or focusing with the keyboard.
|
|
71
|
-
- We rendered the cells in column 2 as the row headers for the table, enabling screen readers to
|
|
72
|
-
automatically announce the topping name even while reading down the Amounts in column 3. When we
|
|
73
|
-
rendered column 1 as row headers, then reading down column 2 (Topping Name) sounded redundant
|
|
74
|
-
because the `Checkbox` names in column 1 are identical to the Topping Name in column 2.
|
|
75
|
-
|
|
76
|
-
<ExampleCodeBlock code={SelectableRows} />
|
|
77
|
-
|
|
78
|
-
### Filterable Column Headers
|
|
79
|
-
|
|
80
|
-
In this example, we demonstrate using the `Popup` component in each column header allowing users to
|
|
81
|
-
search and filter the data on the table. The `Popup` component relies on React Portals to render the
|
|
82
|
-
popup elements at the bottom of the browser's DOM presenting 2 key challenges for accessibility:
|
|
83
|
-
|
|
84
|
-
1. Keyboard focus order of the elements in the popup,
|
|
85
|
-
2. Screen readers' reading order of the content rendered in the browser.
|
|
86
|
-
|
|
87
|
-
Here's what we did about it:
|
|
88
|
-
|
|
89
|
-
- Canvas Kit includes a `usePopupModel` hook, with quite a few additional hooks developers can add
|
|
90
|
-
to their models. In particular, the `useFocusRedirect` hook manages keyboard focus between the
|
|
91
|
-
`<Popup.Target>` button and the popup content.
|
|
92
|
-
- The `useInitialFocus` hook allows developers to specify which element receives keyboard focus when
|
|
93
|
-
the popup appears. In this example, we auto-focused the search input field.
|
|
94
|
-
- To address the reading order of content, we set the `aria-owns` property onto the parent
|
|
95
|
-
`<Table.Header>` component (`<th>` DOM element) with 2 unique `id` values. The first `id` refers
|
|
96
|
-
to the `<Popup.Target>` button and the second refers to the `<Popup.Card>` container element. This
|
|
97
|
-
manually reassigns the column header's `<Popup.Target>` button and the `Popup` contents as
|
|
98
|
-
siblings in the browser's accessibility tree hierarchy. Screen readers **should** read the column
|
|
99
|
-
header buttons and the popup content in sequential order even though they are not siblings in the
|
|
100
|
-
DOM.
|
|
101
|
-
- The `type='description'` variant of the Canvas `Tooltip` is used to communicate the filtered state
|
|
102
|
-
of the column header, and assigned to the accessible description of the column header
|
|
103
|
-
`<TertiaryButton>` component.
|
|
104
|
-
- The Canvas `AriaLiveRegion` component is used to render the "X of Y items" status inside the table
|
|
105
|
-
caption. This enables screen readers to automatically describe the filter state changes of the
|
|
106
|
-
table content to users in real time. We recommend validating whether this use of a live region is
|
|
107
|
-
well supported for your screen reader and browser combinations first.
|
|
108
|
-
|
|
109
|
-
<ExampleCodeBlock code={FilterableColumnHeaders} />
|
|
110
|
-
|
|
111
|
-
### Sortable Column Headers
|
|
112
|
-
|
|
113
|
-
The challenge in this example is to provide all of the necessary information about the interactive
|
|
114
|
-
column headers, the sort state of the column, and instructions about how the table will be sorted
|
|
115
|
-
without giving too much information to users while reading the data cells below.
|
|
116
|
-
|
|
117
|
-
- The `aria-sort` property has been added to each of the `<Table.Header>` components (`<th>` DOM
|
|
118
|
-
element) and updated to `ascending` or `descending` to reflect the current sort state. We
|
|
119
|
-
recommend validating whether this property is well supported for your screen reader and browser
|
|
120
|
-
combinations first.
|
|
121
|
-
- A `<TertiaryButton>` describing the column name is used inside of the `<Table.Header>` component.
|
|
122
|
-
- The `description` variant of the Canvas `Tooltip` component is applied to the button in the column
|
|
123
|
-
header and applied to the accessible description of the button with the `aria-description`
|
|
124
|
-
property. This is used to describe how the column will be sorted when pressed and screen readers
|
|
125
|
-
will only read this description while focusing on the column headers, not while reading the data
|
|
126
|
-
cells below.
|
|
127
|
-
|
|
128
|
-
<ExampleCodeBlock code={SortableColumnHeaders} />
|