Skip to content

Commit 27d2d21

Browse files
committed
resolve A11y warnings
1 parent a524f48 commit 27d2d21

File tree

6 files changed

+28
-10
lines changed

6 files changed

+28
-10
lines changed

components/mdc/Card/Card.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export let color = 'white'
66
export let isClickable = false
77
export let noPadding = false
88
9-
$: tabindex = isClickable ? '0' : undefined
9+
$: tabindex = isClickable ? 0 : undefined
1010
</script>
1111

1212
<style>

components/mdc/Datatable/DatatableCheckbox.svelte

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ onMount(() => dispatch('mounted'))
99
const dispatch = createEventDispatcher()
1010
</script>
1111

12-
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox" on:click>
12+
<td class="mdc-data-table__cell mdc-data-table__cell--checkbox" on:click on:keypress on:keyup on:keydown>
1313
<div class="mdc-checkbox mdc-data-table__row-checkbox">
1414
<input type="checkbox" class="mdc-checkbox__native-control" aria-labelledby={rowId} {disabled} />
1515
<div class="mdc-checkbox__background">

components/mdc/Drawer/Drawer.svelte

+14-4
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,10 @@ const showAppropriateDrawer = () => {
6666
}
6767
6868
const onListClick = (e) => {
69-
modal && closeDrawer()
70-
dismissible && mainContentEl.querySelector('input, button').focus()
69+
if (e.type === 'click' || e.key === 'Enter' || e.key === ' ') {
70+
modal && closeDrawer()
71+
dismissible && mainContentEl.querySelector('input, button').focus()
72+
}
7173
}
7274
7375
const showAppropriateSizeMenu = () => (isNotMini = isAboveMobile() || !miniMenu)
@@ -124,7 +126,13 @@ main {
124126
<slot name="drawer-content-top" />
125127
<!-- override built-in padding so height 100 works correctly without creating a vertical scroller -->
126128
<!-- changing the list to flex causes the margins to not collapse -->
127-
<nav class="mdc-deprecated-list flex column p-0" class:h-100={isFullHeightMenu} on:click={onListClick} bind:this={listElement}>
129+
<nav
130+
class="mdc-deprecated-list flex column p-0"
131+
class:h-100={isFullHeightMenu}
132+
on:click={onListClick}
133+
on:keyup={onListClick}
134+
bind:this={listElement}
135+
>
128136
{#each menuItems as { icon, label, url, urlPattern, hide, button, tooltip }, i}
129137
{#if label === '--break--'}
130138
<span class="grow-1" />
@@ -152,7 +160,9 @@ main {
152160
{/if}
153161
</a>
154162
{:else}
155-
<hr class="mdc-deprecated-list-divider mdc-deprecated-list-divider--inset-leading mdc-deprecated-list-divider--inset-trailing" />
163+
<hr
164+
class="mdc-deprecated-list-divider mdc-deprecated-list-divider--inset-leading mdc-deprecated-list-divider--inset-trailing"
165+
/>
156166
{/if}
157167
</Tooltip.Wrapper>
158168
{#if tooltip}

components/mdc/List/Item.svelte

+3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ img {
4141
class:mdc-deprecated-list-item--disabled={nonInteractive}
4242
data-mdc-dialog-action={$$props['data-mdc-dialog-action']}
4343
on:click
44+
on:keydown
45+
on:keypress
46+
on:keyup
4447
{tabindex}
4548
>
4649
{#if graphicURL}

components/mdc/Select/Select.svelte

+3-1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ $: if (options && mdcSelect.layoutOptions) mdcSelect.layoutOptions()
2626
2727
const recordSelectedID = (event) => (selectedID = event.detail.value)
2828
29+
const isOptionSelected = (option) => option.id === selectedID
30+
2931
onMount(() => {
3032
mdcSelect = new MDCSelect(element)
3133
mdcSelect.listen('MDCSelect:change', recordSelectedID)
@@ -77,7 +79,7 @@ afterUpdate(() => {
7779
<div class="mdc-select__menu mdc-menu mdc-menu-surface" style="width: {width}" role="listbox">
7880
<ul class="mdc-deprecated-list">
7981
{#each options as { id, name } (id)}
80-
<li class="mdc-deprecated-list-item" data-value={id} role="option">
82+
<li class="mdc-deprecated-list-item" data-value={id} role="option" aria-selected={isOptionSelected(id)}>
8183
<span class="mdc-deprecated-list-item__text">{name}</span>
8284
</li>
8385
{/each}

stories/Button.stories.svelte

+6-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import { Meta, Template, Story } from '@storybook/addon-svelte-csf'
33
import { Button } from '../components/mdc'
44
import { copyAndModifyArgs } from './helpers.js'
55
6-
let content = 'Button slot'
7-
86
const args = {
97
raised: true,
108
class: '',
@@ -15,7 +13,7 @@ const args = {
1513
<Meta title="Atoms/Button" component={Button} />
1614

1715
<Template let:args>
18-
<Button {...args} on:click={args['on:click']}>{content}</Button>
16+
<Button {...args} on:click={args['on:click']}>Button slot</Button>
1917
</Template>
2018

2119
<Story name="Primary" {args} />
@@ -27,3 +25,8 @@ const args = {
2725
<Story name="Icon After" args={copyAndModifyArgs(args, { appendIcon: 'arrow_forward' })} />
2826

2927
<Story name="Icon Before" args={copyAndModifyArgs(args, { prependIcon: 'work' })} />
28+
29+
<Story
30+
name="Url"
31+
args={copyAndModifyArgs(args, { url: 'https://github.com/silinternational', raised: false, 'on:click': () => {} })}
32+
/>

0 commit comments

Comments
 (0)