Skip to content

Commit e874ac1

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

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>
@@ -476,6 +483,7 @@
476483
<button
477484
type="button"
478485
class:bx--table-expand__button={true}
486+
aria-controls={`expandable-row-${row.id}`}
479487
aria-label={expandedRows[row.id]
480488
? "Collapse current row"
481489
: "Expand current row"}
@@ -492,7 +500,10 @@
492500
});
493501
}}
494502
>
495-
<ChevronRight class="bx--table-expand__svg" />
503+
<ChevronRight
504+
aria-hidden="true"
505+
class="bx--table-expand__svg"
506+
/>
496507
</button>
497508
{/if}
498509
</TableCell>
@@ -560,6 +571,7 @@
560571
561572
{#if expandable}
562573
<tr
574+
id={`expandable-row-${row.id}`}
563575
data-child-row
564576
class:bx--expandable-row={true}
565577
on:mouseenter={() => {

0 commit comments

Comments
 (0)