Skip to content

Commit cc11f87

Browse files
committed
fix: nav control focus trap, close #36
1 parent 4142bc0 commit cc11f87

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/client/internals/NavControls.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<script setup lang="ts">
2-
import { computed, defineProps } from 'vue'
2+
import { computed, defineProps, ref } from 'vue'
33
import { isDark, toggleDark } from '../logic/dark'
44
import { hasNext, hasPrev, prev, next, total, isPresenter, currentPage, downloadPDF } from '../logic/nav'
5-
import { toggleOverview, showEditor, showInfoDialog, fullscreen, breakpoints } from '../state'
5+
import { toggleOverview, showEditor, showInfoDialog, fullscreen, breakpoints, activeElement } from '../state'
66
import { configs } from '../env'
77
import RecordingControls from './RecordingControls.vue'
88
import Settings from './Settings.vue'
@@ -19,10 +19,16 @@ const { isFullscreen, toggle: toggleFullscreen } = fullscreen
1919
2020
const presenterLink = computed(() => `${location.origin}/presenter/${currentPage.value}`)
2121
const nonPresenterLink = computed(() => `${location.origin}/${currentPage.value}`)
22+
23+
const root = ref<HTMLDivElement>()
24+
const onMouseLeave = () => {
25+
if (root.value && activeElement.value && root.value.contains(activeElement.value))
26+
activeElement.value.blur()
27+
}
2228
</script>
2329

2430
<template>
25-
<nav class="flex flex-wrap-reverse text-xl p-2 gap-1">
31+
<nav ref="root" class="flex flex-wrap-reverse text-xl p-2 gap-1" @mouseleave="onMouseLeave">
2632
<button class="icon-btn" @click="toggleFullscreen">
2733
<carbon:minimize v-if="isFullscreen" />
2834
<carbon:maximize v-else />

0 commit comments

Comments
 (0)