Skip to content

Commit 275d2b9

Browse files
committed
fix(Drawer): fix A11y warning in Drawer
1 parent bd6811f commit 275d2b9

File tree

1 file changed

+49
-42
lines changed

1 file changed

+49
-42
lines changed

components/mdc/Drawer/Drawer.svelte

Lines changed: 49 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ main {
118118
.main-content-height {
119119
height: var(--mdc-drawer-height);
120120
}
121+
.drawer-menu {
122+
display: flex;
123+
flex-direction: column;
124+
padding: 0;
125+
}
121126
</style>
122127

123128
<svelte:window on:resize={showAppropriateThings} />
@@ -138,50 +143,52 @@ main {
138143
<slot name="drawer-content-top" />
139144
<!-- override built-in padding so height 100 works correctly without creating a vertical scroller -->
140145
<!-- changing the list to flex causes the margins to not collapse -->
141-
<nav
142-
class="mdc-deprecated-list flex column p-0"
143-
class:h-100={isFullHeightMenu}
144-
on:click={onListClick}
145-
on:keyup={onListClick}
146-
bind:this={listElement}
147-
>
148-
{#each menuItems as { icon, label, url, urlPattern, hide, button, tooltip }, i}
149-
{#if label === '--break--'}
150-
<span class="grow-1" />
151-
{:else if !hide}
152-
<Tooltip.Wrapper ariaDescribedBy={label + '-tooltip'}>
153-
{#if button && isNotMini}
154-
<Button class="m-1" raised prependIcon={icon} {url}>{label}</Button>
155-
{:else if button}
156-
<IconButton class="mdc-theme--primary pl-1" {icon} ariaLabel={label} {url} />
157-
{:else if url}
158-
<a
159-
class="mdc-deprecated-list-item"
160-
class:mdc-deprecated-list-item--activated={isMenuItemActive(currentUrl, url, urlPattern)}
161-
href={url}
162-
aria-current={isMenuItemActive(currentUrl, url, urlPattern) ? 'page' : null}
163-
tabindex={i === 0 ? 0 : undefined}
164-
>
165-
<span class="mdc-deprecated-list-item__ripple" />
166-
{#if icon}
167-
<i class="material-icons mdc-deprecated-list-item__graphic" aria-hidden="true">{icon}</i>
168-
{/if}
169-
170-
{#if label && isNotMini}
171-
<span class="mdc-deprecated-list-item__text">{label}</span>
172-
{/if}
173-
</a>
174-
{:else}
175-
<hr
176-
class="mdc-deprecated-list-divider mdc-deprecated-list-divider--inset-leading mdc-deprecated-list-divider--inset-trailing"
177-
/>
146+
<nav class:h-100={isFullHeightMenu} bind:this={listElement}>
147+
<div
148+
class="drawer-menu mdc-deprecated-list"
149+
role="button"
150+
tabindex="-1"
151+
on:click={onListClick}
152+
on:keyup={onListClick}
153+
>
154+
{#each menuItems as { icon, label, url, urlPattern, hide, button, tooltip }, i}
155+
{#if label === '--break--'}
156+
<span class="grow-1" />
157+
{:else if !hide}
158+
<Tooltip.Wrapper ariaDescribedBy={label + '-tooltip'}>
159+
{#if button && isNotMini}
160+
<Button class="m-1" raised prependIcon={icon} {url}>{label}</Button>
161+
{:else if button}
162+
<IconButton class="mdc-theme--primary pl-1" {icon} ariaLabel={label} {url} />
163+
{:else if url}
164+
<a
165+
class="mdc-deprecated-list-item"
166+
class:mdc-deprecated-list-item--activated={isMenuItemActive(currentUrl, url, urlPattern)}
167+
href={url}
168+
aria-current={isMenuItemActive(currentUrl, url, urlPattern) ? 'page' : null}
169+
tabindex={i === 0 ? 0 : undefined}
170+
>
171+
<span class="mdc-deprecated-list-item__ripple" />
172+
{#if icon}
173+
<i class="material-icons mdc-deprecated-list-item__graphic" aria-hidden="true">{icon}</i>
174+
{/if}
175+
176+
{#if label && isNotMini}
177+
<span class="mdc-deprecated-list-item__text">{label}</span>
178+
{/if}
179+
</a>
180+
{:else}
181+
<hr
182+
class="mdc-deprecated-list-divider mdc-deprecated-list-divider--inset-leading mdc-deprecated-list-divider--inset-trailing"
183+
/>
184+
{/if}
185+
</Tooltip.Wrapper>
186+
{#if tooltip}
187+
<Tooltip tooltipID={label + '-tooltip'}>{tooltip}</Tooltip>
178188
{/if}
179-
</Tooltip.Wrapper>
180-
{#if tooltip}
181-
<Tooltip tooltipID={label + '-tooltip'}>{tooltip}</Tooltip>
182189
{/if}
183-
{/if}
184-
{/each}
190+
{/each}
191+
</div>
185192
</nav>
186193
</div>
187194
</aside>

0 commit comments

Comments
 (0)