Skip to content

Commit 82dd821

Browse files
committed
fixes
1 parent 30bad4e commit 82dd821

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

apps/svelte.dev/src/lib/components/SelectIcon.svelte

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { Icon } from '@sveltejs/site-kit/components';
66
import type { Snippet } from 'svelte';
77
8-
let { children }: { children: Snippet } = $props();
8+
let { children, label }: { children: Snippet; label: string } = $props();
99
1010
let open = $state(false);
1111
@@ -25,6 +25,15 @@
2525
<details
2626
class="examples-select"
2727
bind:open
28+
ontogglecapture={(e) => {
29+
const details = e.target as HTMLDetailsElement;
30+
31+
if (details === e.currentTarget || !details.open) {
32+
return;
33+
}
34+
35+
details.scrollIntoView();
36+
}}
2837
ontoggle={(e) => {
2938
const details = e.currentTarget;
3039
if (!details.open) return;
@@ -36,6 +45,7 @@
3645

3746
// except parents of the current one
3847
const current = details.querySelector(`[href="${$page.url.pathname}"]`);
48+
if (!current) return;
3949

4050
let node = current as Element;
4151

@@ -44,9 +54,12 @@
4454
(node as HTMLDetailsElement).open = true;
4555
}
4656
}
57+
58+
current.scrollIntoView();
59+
current.focus();
4760
}}
4861
>
49-
<summary class="raised icon"><Icon name="menu" /></summary>
62+
<summary class="raised icon" aria-label={label}><Icon name="menu" /></summary>
5063

5164
<!-- svelte-ignore a11y_click_events_have_key_events, a11y_no_static_element_interactions (handled by <svelte:window>) -->
5265
<div class="modal-background" onclick={() => (open = false)}></div>

apps/svelte.dev/src/routes/(authed)/playground/[id]/AppControls.svelte

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,7 @@
181181
<svelte:window on:keydown={handleKeydown} />
182182

183183
<SecondaryNav>
184-
<SelectIcon
185-
bind:this={select}
186-
title="examples"
187-
value={gist.id}
188-
onchange={async (e) => {
189-
goto(`/playground/${e.currentTarget.value}`);
190-
}}
191-
>
184+
<SelectIcon label="Examples">
192185
<div class="secondary-nav-dropdown">
193186
<a class="create-new" href="/playground/untitled">Create new</a>
194187

apps/svelte.dev/src/routes/tutorial/[...slug]/Controls.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
</script>
1717

1818
<SecondaryNav>
19-
<SelectIcon>
19+
<SelectIcon label="Menu">
2020
<div class="secondary-nav-dropdown">
2121
{#each index as part}
2222
<details>

0 commit comments

Comments
 (0)