Skip to content

Commit 7627751

Browse files
committed
Add titles for components for better accessibility
1 parent eb3e97f commit 7627751

File tree

4 files changed

+34
-3
lines changed

4 files changed

+34
-3
lines changed

src/lib/components/Table/ColumnsMenu.svelte

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
type="button"
1717
class="btn btn-sm variant-filled-primary rounded-full order-last"
1818
aria-label="Open menu to hide/show columns"
19+
title="Open menu to hide/show columns"
1920
use:popup={popupCombobox}>Columns</button
2021
>
2122

@@ -26,9 +27,10 @@
2627
{#each columns as column}
2728
<div class="flex gap-3 items-center">
2829
<input
29-
aria-label="Toggle column visibility for column {column.label}"
30+
aria-label={`${column.visible ? 'Hide' : 'Show'} ${column.label} column`}
3031
type="checkbox"
3132
bind:checked={column.visible}
33+
title={`${column.visible ? 'Hide' : 'Show'} ${column.label} column`}
3234
disabled={columns.filter((c) => c.visible).length === 1 && column.visible}
3335
/>
3436
<span>{column.label}</span>

src/lib/components/Table/TableContent.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,12 +404,14 @@
404404
type="text"
405405
bind:value={searchValue}
406406
placeholder="Search rows..."
407+
title="Search rows"
407408
id="{tableId}-search"
408409
/><button
409410
type="reset"
410411
id="{tableId}-searchReset"
411412
class="absolute right-3 items-center"
412413
aria-label="Clear search"
414+
title="Clear search"
413415
on:click|preventDefault={() => {
414416
if (serverSide && !sendModel) {
415417
throw new Error('Server-side configuration is missing');
@@ -426,6 +428,7 @@
426428
type="submit"
427429
id="{tableId}-searchSubmit"
428430
class="btn variant-filled-primary"
431+
title="Search"
429432
on:click|preventDefault={() => {
430433
if (serverSide && !sendModel) {
431434
throw new Error('Server-side configuration is missing');
@@ -453,6 +456,10 @@
453456
size="sm"
454457
checked={fitToScreen}
455458
id="{tableId}-toggle"
459+
title={fitToScreen ? 'Fit table data to screen' : `Don't fit table data to screen`}
460+
aria-label={fitToScreen
461+
? 'Fit table data to screen'
462+
: `Don't fit table data to screen`}
456463
on:change={() => (fitToScreen = !fitToScreen)}>Fit to screen</SlideToggle
457464
>
458465
{/if}
@@ -463,6 +470,7 @@
463470
<button
464471
type="button"
465472
class="btn btn-sm variant-filled-primary rounded-full order-last"
473+
title="Reset sizing of columns and rows"
466474
on:click|preventDefault={() =>
467475
resetResize($headerRows, $pageRows, tableId, columns, resizable)}
468476
>Reset sizing</button
@@ -472,6 +480,7 @@
472480
<button
473481
type="button"
474482
class="btn btn-sm variant-filled-primary rounded-full order-last"
483+
title="Export table data as CSV"
475484
on:click|preventDefault={() => exportAsCsv(tableId, $exportedData)}
476485
>Export as CSV</button
477486
>
@@ -517,6 +526,11 @@
517526
class:cursor-pointer={!props.sort.disabled}
518527
on:click={props.sort.toggle}
519528
on:keydown={props.sort.toggle}
529+
title={props.sort.order === 'asc'
530+
? `Sort by ${cell.label} column in descending order`
531+
: props.sort.order === 'desc'
532+
? `Remove sorting by ${cell.label} column`
533+
: `Sort by ${cell.label} column in ascending order`}
520534
>
521535
{cell.render()}
522536
</span>

src/lib/components/Table/TableFilter.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,8 @@
240240
type="button"
241241
use:popup={popupFeatured}
242242
id="{popupId}-button"
243-
aria-label="Open filter menu for column {id}"
243+
aria-label="Open filter menu for {id} column"
244+
title="Open filter menu for {id} column"
244245
>
245246
<Fa icon={faFilter} size="12" />
246247
</button>
@@ -251,6 +252,7 @@
251252
class="btn variant-filled-primary btn-sm"
252253
type="button"
253254
aria-label="Clear Filters"
255+
title="Clear Filters"
254256
on:click|preventDefault={() => {
255257
// Set the defaults when cleared
256258
clearFilters();
@@ -269,13 +271,15 @@
269271
<select
270272
class="select border border-primary-500 text-sm p-1"
271273
aria-label="Show rows with value that"
274+
title="Show rows with value that"
272275
on:change={(e) => optionChangeHandler(e, index)}
273276
bind:value={dropdown.option}
274277
>
275278
{#each options[type] as option (option)}
276279
<option
277280
value={option.value}
278281
aria-label={option.label}
282+
title={option.label}
279283
selected={dropdown.option === option.value}
280284
disabled={Object.keys($filters[id]).includes(option.value) &&
281285
dropdown.option !== option.value}>{option.label}</option
@@ -286,6 +290,7 @@
286290
<div
287291
class="btn variant-filled-warning btn-sm h-full"
288292
aria-label="Remove filter"
293+
title="Remove filter"
289294
on:click|preventDefault={() => removeFilter(dropdown.option)}
290295
on:keydown|preventDefault={() => removeFilter(dropdown.option)}
291296
>
@@ -301,6 +306,7 @@
301306
on:input={(e) => valueChangeHandler(e, index)}
302307
bind:value={dropdown.value}
303308
aria-label="Filter value"
309+
title="Filter value"
304310
/>
305311
{:else}
306312
<input
@@ -309,6 +315,7 @@
309315
on:input={(e) => valueChangeHandler(e, index)}
310316
bind:value={dropdown.formValue}
311317
aria-label="Filter value"
318+
title="Filter value"
312319
/>
313320
{/if}
314321
</div>
@@ -328,6 +335,7 @@
328335
addFilter(remainingFilters[0].value, undefined);
329336
}}
330337
aria-label="Add filter"
338+
title="Add filter"
331339
>
332340
<div class="flex gap-1 items-center"><Fa icon={faPlus} />Add Filter</div>
333341
</div>
@@ -336,6 +344,7 @@
336344
class="btn variant-filled-primary btn-sm"
337345
type="button"
338346
aria-label="Apply filters"
347+
title="Apply filters"
339348
on:click|preventDefault={() => {
340349
$pageIndex = 0;
341350
$filterValue = $filters[id];

src/lib/components/Table/TablePagination.svelte

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
</select> -->
6464

6565
<button
66-
aria-label="Open menu to select number of items per page"
66+
aria-label="Open menu to select number of items to display per page"
67+
title="Open menu to select number of items to display per page"
6768
class="btn variant-filled-primary w-20 justify-between"
6869
use:popup={pageSizePopup}
6970
>
@@ -87,6 +88,7 @@
8788
class="btn btn-sm variant-filled-primary"
8889
on:click|preventDefault={goToFirstPage}
8990
aria-label="Go to first page"
91+
title="Go to first page"
9092
disabled={goToFirstPageDisabled}
9193
id="{id}-first"
9294
>
@@ -96,6 +98,7 @@
9698
class="btn btn-sm variant-filled-primary"
9799
id="{id}-previous"
98100
aria-label="Go to previous page"
101+
title="Go to previous page"
99102
on:click|preventDefault={goToPreviousPage}
100103
disabled={goToPreviousPageDisabled}><Fa icon={faAngleLeft} /></button
101104
>
@@ -105,19 +108,22 @@
105108
value={$pageIndex + 1}
106109
max={$pageCount}
107110
aria-label="Current page"
111+
title="Current page"
108112
min={1}
109113
on:change={handleChange}
110114
/>
111115
<button
112116
class="btn btn-sm variant-filled-primary"
113117
id="{id}-next"
114118
aria-label="Go to next page"
119+
title="Go to next page"
115120
on:click|preventDefault={goToNextPage}
116121
disabled={goToNextPageDisabled}><Fa icon={faAngleRight} /></button
117122
>
118123
<button
119124
class="btn btn-sm variant-filled-primary"
120125
aria-label="Go to last page"
126+
title="Go to last page"
121127
id="{id}-last"
122128
on:click|preventDefault={goToLastPage}
123129
disabled={goToLastPageDisabled}><Fa icon={faAnglesRight} /></button

0 commit comments

Comments
 (0)