Skip to content

Commit fe36522

Browse files
committed
fix(data-table): improve expandable accessibility (#2086)
1 parent eb1567a commit fe36522

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/DataTable/DataTable.svelte

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,21 @@
354354
<button
355355
type="button"
356356
class:bx--table-expand__button={true}
357+
aria-label={expanded ? "Collapse all rows" : "Expand all rows"}
358+
aria-controls={expandableRowIds
359+
.map((id) => `expandable-row-${id}`)
360+
.join(" ")}
357361
on:click={() => {
358362
expanded = !expanded;
359363
expandedRowIds = expanded ? expandableRowIds : [];
360364
361365
dispatch("click:header--expand", { expanded });
362366
}}
363367
>
364-
<ChevronRight class="bx--table-expand__svg" />
368+
<ChevronRight
369+
aria-hidden="true"
370+
class="bx--table-expand__svg"
371+
/>
365372
</button>
366373
{/if}
367374
</th>
@@ -474,6 +481,7 @@
474481
<button
475482
type="button"
476483
class:bx--table-expand__button={true}
484+
aria-controls={`expandable-row-${row.id}`}
477485
aria-label={expandedRows[row.id]
478486
? "Collapse current row"
479487
: "Expand current row"}
@@ -490,7 +498,10 @@
490498
});
491499
}}
492500
>
493-
<ChevronRight class="bx--table-expand__svg" />
501+
<ChevronRight
502+
aria-hidden="true"
503+
class="bx--table-expand__svg"
504+
/>
494505
</button>
495506
{/if}
496507
</TableCell>
@@ -554,6 +565,7 @@
554565
555566
{#if expandable}
556567
<tr
568+
id={`expandable-row-${row.id}`}
557569
data-child-row
558570
class:bx--expandable-row={true}
559571
on:mouseenter={() => {

0 commit comments

Comments
 (0)