Commit 8e2384e70d
Unsigned
Layout: unified · split
docs/.vitepress/theme/Layout.vue +12 −10
| @@ -175,18 +175,20 @@ onMounted(() => { | |||
| 175 | 175 | ||
| 176 | // Arrow key scrolling + Escape close for desktop sidebar | 176 | // Arrow key scrolling + Escape close for desktop sidebar |
| 177 | useEventListener(document, 'keydown', (e: KeyboardEvent) => { | 177 | useEventListener(document, 'keydown', (e: KeyboardEvent) => { |
| 178 | if (!homeSidebarOpen.value || !sidebarRef.value) return | 178 | if (e.key !== 'ArrowDown' && e.key !== 'ArrowUp' && e.key !== 'Escape') return |
| 179 | |||
| 179 | if (e.key === 'Escape') { | 180 | if (e.key === 'Escape') { |
| 180 | homeSidebarOpen.value = false | 181 | if (homeSidebarOpen.value) homeSidebarOpen.value = false |
| 181 | return | 182 | return |
| 182 | } | 183 | } |
| 183 | if (e.key === 'ArrowDown') { | 184 | |
| 184 | e.preventDefault() | 185 | const target = homeSidebarOpen.value |
| 185 | sidebarRef.value.scrollBy({ top: 60, behavior: 'smooth' }) | 186 | ? sidebarRef.value |
| 186 | } else if (e.key === 'ArrowUp') { | 187 | : !isHome.value ? document.querySelector<HTMLElement>('.VPSidebar') : null |
| 187 | e.preventDefault() | 188 | if (!target) return |
| 188 | sidebarRef.value.scrollBy({ top: -60, behavior: 'smooth' }) | 189 | |
| 189 | } | 190 | e.preventDefault() |
| 191 | target.scrollBy({ top: e.key === 'ArrowDown' ? 60 : -60, behavior: 'smooth' }) | ||
| 190 | }) | 192 | }) |
| 191 | 193 | ||
| 192 | // Close home NavScreen on outside click | 194 | // Close home NavScreen on outside click |
| @@ -256,8 +258,8 @@ onUnmounted(() => { | |||
| 256 | </div> | 258 | </div> |
| 257 | <nav id="VPSidebarNav" class="home-sidebar-nav"> | 259 | <nav id="VPSidebarNav" class="home-sidebar-nav"> |
| 258 | <VPSidebarGroup :items="homeSidebarGroups" /> | 260 | <VPSidebarGroup :items="homeSidebarGroups" /> |
| 261 | <SidebarCard /> | ||
| 259 | </nav> | 262 | </nav> |
| 260 | <SidebarCard /> | ||
| 261 | </aside> | 263 | </aside> |
| 262 | </Transition> | 264 | </Transition> |
| 263 | </template> | 265 | </template> |
docs/.vitepress/theme/components/Search.vue +1
| @@ -95,6 +95,7 @@ const { activate } = useFocusTrap(el, { | |||
| 95 | allowOutsideClick: true, | 95 | allowOutsideClick: true, |
| 96 | clickOutsideDeactivates: true, | 96 | clickOutsideDeactivates: true, |
| 97 | escapeDeactivates: true, | 97 | escapeDeactivates: true, |
| 98 | returnFocusOnDeactivate: false, | ||
| 98 | initialFocus: () => { | 99 | initialFocus: () => { |
| 99 | return searchInput.value | 100 | return searchInput.value |
| 100 | } | 101 | } |