Skip to content

Commit 27a6875

Browse files
committed
fix(table): fix accessibility audit failures
- Correct ARIA role for column headers (`colheader` -> `columnheader`) - Add accessible label to the row expand/collapse toggle button - Add `aria-controls` linking the toggle button to its expansion content Closes #2813 Assisted-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1377f14 commit 27a6875

5 files changed

Lines changed: 13 additions & 3 deletions

File tree

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@patternfly/elements": patch
3+
---
4+
`<pf-table>`: fix accessibility audit failures
5+
6+
- Fix column header ARIA role (`colheader` -> `columnheader`)
7+
- Add accessible label to the row expand/collapse toggle button
8+
- Add `aria-controls` linking the toggle button to its expansion content

elements/pf-table/context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import { createContextWithRoot } from '@patternfly/pfe-core/functions/context.js
22

33
export const thRoleContext: {
44
__context__: unknown;
5-
} = createContextWithRoot<'rowheader' | 'colheader'>('pf-th-role');
5+
} = createContextWithRoot<'rowheader' | 'columnheader'>('pf-th-role');

elements/pf-table/pf-th.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export class PfTh extends LitElement {
5151
@property() key!: string;
5252

5353
@consume({ context: thRoleContext })
54-
private contextualRole: 'colheader' | 'rowheader' = 'rowheader';
54+
private contextualRole: 'columnheader' | 'rowheader' = 'rowheader';
5555

5656
override connectedCallback(): void {
5757
super.connectedCallback();

elements/pf-table/pf-thead.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { provide } from '@lit/context';
1414
export class PfThead extends LitElement {
1515
static readonly styles: CSSStyleSheet[] = [styles];
1616

17-
@provide({ context: thRoleContext }) private thRowContext = 'colheader';
17+
@provide({ context: thRoleContext }) private thRowContext = 'columnheader';
1818

1919
connectedCallback(): void {
2020
super.connectedCallback();

elements/pf-table/pf-tr.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ export class PfTr extends LitElement {
109109
<pf-td id="toggle-cell">
110110
<pf-button id="toggle-button"
111111
aria-expanded=${String(this.expanded) as 'true' | 'false'}
112+
aria-controls=${ifDefined(this.expanded ? 'expansion' : undefined)}
112113
plain
114+
label="Details"
113115
@click=${this.#onClick}>
114116
<pf-icon id="toggle-icon"
115117
icon="angle-right"

0 commit comments

Comments
 (0)