Skip to content

Commit f34b5d0

Browse files
committed
#1892 Add ARIA labels for better accessibility
1 parent 6f5aecb commit f34b5d0

File tree

6 files changed

+37
-3
lines changed

6 files changed

+37
-3
lines changed

src/lib/components/Table/ColumnsMenu.svelte

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
<button
1616
type="button"
1717
class="btn btn-sm variant-filled-primary rounded-full order-last"
18+
aria-label="Open menu to hide/show columns"
1819
use:popup={popupCombobox}>Columns</button
1920
>
2021

@@ -25,6 +26,7 @@
2526
{#each columns as column}
2627
<div class="flex gap-3 items-center">
2728
<input
29+
aria-label="Toggle column visibility for column {column.label}"
2830
type="checkbox"
2931
bind:checked={column.visible}
3032
disabled={columns.filter((c) => c.visible).length === 1 && column.visible}

src/lib/components/Table/TableContent.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@
394394
} else {
395395
sendModel.q = searchValue;
396396
}
397-
397+
398398
$filterValue = searchValue;
399399
}}
400400
>
@@ -409,6 +409,7 @@
409409
type="reset"
410410
id="{tableId}-searchReset"
411411
class="absolute right-3 items-center"
412+
aria-label="Clear search"
412413
on:click|preventDefault={() => {
413414
if (serverSide && !sendModel) {
414415
throw new Error('Server-side configuration is missing');

src/lib/components/Table/TableFilter.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@
240240
type="button"
241241
use:popup={popupFeatured}
242242
id="{popupId}-button"
243+
aria-label="Open filter menu for column {id}"
243244
>
244245
<Fa icon={faFilter} size="12" />
245246
</button>
@@ -249,6 +250,7 @@
249250
<button
250251
class="btn variant-filled-primary btn-sm"
251252
type="button"
253+
aria-label="Clear Filters"
252254
on:click|preventDefault={() => {
253255
// Set the defaults when cleared
254256
clearFilters();
@@ -273,6 +275,7 @@
273275
{#each options[type] as option (option)}
274276
<option
275277
value={option.value}
278+
aria-label={option.label}
276279
selected={dropdown.option === option.value}
277280
disabled={Object.keys($filters[id]).includes(option.value) &&
278281
dropdown.option !== option.value}>{option.label}</option
@@ -282,6 +285,7 @@
282285
{#if dropdowns.length > 1}
283286
<div
284287
class="btn variant-filled-warning btn-sm h-full"
288+
aria-label="Remove filter"
285289
on:click|preventDefault={() => removeFilter(dropdown.option)}
286290
on:keydown|preventDefault={() => removeFilter(dropdown.option)}
287291
>
@@ -296,13 +300,15 @@
296300
class="input p-1 border border-primary-500"
297301
on:input={(e) => valueChangeHandler(e, index)}
298302
bind:value={dropdown.value}
303+
aria-label="Filter value"
299304
/>
300305
{:else}
301306
<input
302307
type="date"
303308
class="input p-1 border border-primary-500"
304309
on:input={(e) => valueChangeHandler(e, index)}
305310
bind:value={dropdown.formValue}
311+
aria-label="Filter value"
306312
/>
307313
{/if}
308314
</div>
@@ -321,13 +327,15 @@
321327
on:keydown|stopPropagation={() => {
322328
addFilter(remainingFilters[0].value, undefined);
323329
}}
330+
aria-label="Add filter"
324331
>
325332
<div class="flex gap-1 items-center"><Fa icon={faPlus} />Add Filter</div>
326333
</div>
327334
{/if}
328335
<button
329336
class="btn variant-filled-primary btn-sm"
330337
type="button"
338+
aria-label="Apply filters"
331339
on:click|preventDefault={() => {
332340
$pageIndex = 0;
333341
$filterValue = $filters[id];

src/lib/components/Table/TableFilterServer.svelte

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@
233233
type="button"
234234
use:popup={popupFeatured}
235235
id="{popupId}-button"
236+
aria-label="Open filter menu for column {id}"
236237
>
237238
<Fa icon={faFilter} size="12" />
238239
</button>
@@ -242,6 +243,7 @@
242243
<button
243244
class="btn variant-filled-primary btn-sm"
244245
type="button"
246+
aria-label="Clear Filters"
245247
on:click|preventDefault={() => {
246248
// Set the defaults when cleared
247249
clearFilters();
@@ -264,6 +266,7 @@
264266
{#each options[type] as option (option)}
265267
<option
266268
value={option.value}
269+
aria-label={option.label}
267270
selected={dropdown.option === option.value}
268271
disabled={Object.keys($filters[id]).includes(option.value) &&
269272
dropdown.option !== option.value}>{option.label}</option
@@ -275,7 +278,8 @@
275278
class="btn variant-filled-warning btn-sm h-full"
276279
on:click|preventDefault={() => removeFilter(dropdown.option)}
277280
on:keydown|preventDefault={() => removeFilter(dropdown.option)}
278-
>
281+
aria-label="Remove filter"
282+
>
279283
<Fa icon={faXmark} />
280284
</div>
281285
{/if}
@@ -294,13 +298,15 @@
294298
class="input p-1 border border-primary-500"
295299
on:input={(e) => valueChangeHandler(e, index)}
296300
bind:value={dropdown.value}
301+
aria-label="Filter value"
297302
/>
298303
{:else}
299304
<input
300305
type="date"
301306
class="input p-1 border border-primary-500"
302307
on:input={(e) => valueChangeHandler(e, index)}
303308
bind:value={dropdown.value}
309+
aria-label="Filter value"
304310
/>
305311
{/if}
306312
</div>
@@ -313,6 +319,7 @@
313319
{#if remainingFilters.length}
314320
<div
315321
class="btn variant-filled-secondary btn-sm cursor-pointer"
322+
aria-label="Add filter"
316323
on:click|stopPropagation={() => {
317324
addFilter(remainingFilters[0].value, undefined);
318325
}}
@@ -326,6 +333,7 @@
326333
<button
327334
class="btn variant-filled-primary btn-sm"
328335
type="button"
336+
aria-label="Apply filters"
329337
on:click|preventDefault={applyFilters}>Apply</button
330338
>
331339
</div>

src/lib/components/Table/TablePagination.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@
6262
{/each}
6363
</select> -->
6464

65-
<button class="btn variant-filled-primary w-20 justify-between" use:popup={pageSizePopup}>
65+
<button
66+
aria-label="Open menu to select number of items per page"
67+
class="btn variant-filled-primary w-20 justify-between"
68+
use:popup={pageSizePopup}
69+
>
6670
<span class="capitalize font-semibold">{pageSizeDropdownValue}</span>
6771
<Fa icon={faChevronDown} size="xs" />
6872
</button>
@@ -82,6 +86,7 @@
8286
<button
8387
class="btn btn-sm variant-filled-primary"
8488
on:click|preventDefault={goToFirstPage}
89+
aria-label="Go to first page"
8590
disabled={goToFirstPageDisabled}
8691
id="{id}-first"
8792
>
@@ -90,6 +95,7 @@
9095
<button
9196
class="btn btn-sm variant-filled-primary"
9297
id="{id}-previous"
98+
aria-label="Go to previous page"
9399
on:click|preventDefault={goToPreviousPage}
94100
disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
95101
>
@@ -98,17 +104,20 @@
98104
class="input border border-primary-500 rounded flex w-24"
99105
value={$pageIndex + 1}
100106
max={$pageCount}
107+
aria-label="Current page"
101108
min={1}
102109
on:change={handleChange}
103110
/>
104111
<button
105112
class="btn btn-sm variant-filled-primary"
106113
id="{id}-next"
114+
aria-label="Go to next page"
107115
on:click|preventDefault={goToNextPage}
108116
disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
109117
>
110118
<button
111119
class="btn btn-sm variant-filled-primary"
120+
aria-label="Go to last page"
112121
id="{id}-last"
113122
on:click|preventDefault={goToLastPage}
114123
disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button

src/lib/components/Table/TablePaginationServer.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<select
7474
name="pageSize"
7575
id="{id}-pageSize"
76+
aria-label="Open menu to select number of items per page"
7677
class="select variant-filled-primary w-min font-bold"
7778
bind:value={$pageSize}
7879
>
@@ -86,19 +87,22 @@
8687
class="btn btn-sm variant-filled-primary"
8788
on:click|preventDefault={() => goTo('first')}
8889
disabled={goToFirstPageDisabled}
90+
aria-label="Go to first page"
8991
id="{id}-first"
9092
>
9193
<Fa icon={faAnglesLeft} /></button
9294
>
9395
<button
9496
class="btn btn-sm variant-filled-primary"
9597
id="{id}-previous"
98+
aria-label="Go to previous page"
9699
on:click|preventDefault={() => goTo('previous')}
97100
disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
98101
>
99102
<input
100103
type="number"
101104
class="input border border-primary-500 rounded flex w-24"
105+
aria-label="Current page"
102106
value={$pageIndex + 1}
103107
max={pageCount}
104108
min={1}
@@ -108,11 +112,13 @@
108112
class="btn btn-sm variant-filled-primary"
109113
id="{id}-next"
110114
on:click|preventDefault={() => goTo('next')}
115+
aria-label="Go to next page"
111116
disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
112117
>
113118
<button
114119
class="btn btn-sm variant-filled-primary"
115120
id="{id}-last"
121+
aria-label="Go to last page"
116122
on:click|preventDefault={() => goTo('last')}
117123
disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button
118124
>

0 commit comments

Comments
 (0)