Skip to content

Commit f6bd3e8

Browse files
committed
fix: prevent Twoslash poppers from persisting between slides
1 parent e59e631 commit f6bd3e8

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

packages/client/composables/useNav.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { slides } from '#slidev/slides'
55
import { clamp } from '@antfu/utils'
66
import { parseRangeString } from '@slidev/parser/utils'
77
import { createSharedComposable } from '@vueuse/core'
8+
import { hideAllPoppers } from 'floating-vue'
89
import { computed, ref, watch } from 'vue'
910
import { useRoute, useRouter } from 'vue-router'
1011
import { CLICKS_MAX } from '../constants'
@@ -118,6 +119,8 @@ export function useNavBase(
118119

119120
watch(currentSlideRoute, (next, prev) => {
120121
navDirection.value = next.no - prev.no
122+
if (prev)
123+
hideAllPoppers()
121124
})
122125

123126
async function openInEditor(url?: string) {

packages/client/internals/SlidesShow.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { SlideRoute } from '@slidev/types'
33
import { GlobalBottom, GlobalTop } from '#slidev/global-layers'
4-
import { recomputeAllPoppers } from 'floating-vue'
4+
import { hideAllPoppers, recomputeAllPoppers } from 'floating-vue'
55
import { computed, shallowRef, TransitionGroup, watchEffect } from 'vue'
66
import { createFixedClicks } from '../composables/useClicks'
77
import { useNav } from '../composables/useNav'
@@ -39,12 +39,18 @@ watchEffect(() => {
3939
preloadRoute(currentSlideRoute.value)
4040
preloadRoute(prevRoute.value)
4141
preloadRoute(nextRoute.value)
42+
setTimeout(() => {
43+
hideAllPoppers()
44+
}, 150)
4245
})
4346
// preload all slides after 3s
4447
watchEffect((onCleanup) => {
4548
const routes = slides.value
4649
const timeout = setTimeout(() => {
4750
routes.forEach(preloadRoute)
51+
setTimeout(() => {
52+
hideAllPoppers()
53+
}, 150)
4854
}, 3000)
4955
onCleanup(() => clearTimeout(timeout))
5056
})

0 commit comments

Comments
 (0)