Skip to content

Conversation

elecmonkey
Copy link
Contributor

Prevent Twoslash poppers from persisting when navigating across slides by watching currentSlideRoute.

Fixes #2202

Copy link

netlify bot commented Sep 27, 2025

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit e381c42
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/68d8b5e75db3f5000816272b
😎 Deploy Preview https://deploy-preview-2292--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

pkg-pr-new bot commented Sep 27, 2025

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2292

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2292

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2292

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2292

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2292

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2292

commit: e381c42

@elecmonkey
Copy link
Contributor Author

The changes make a test fail. I think I should not fix this issue by using v-if, as it will destroy the components when navigation happens.

@elecmonkey elecmonkey force-pushed the fix/slidev-twoslash-popover branch from aae15c7 to f6bd3e8 Compare September 27, 2025 15:38
@elecmonkey
Copy link
Contributor Author

The fixed popers displayed by ^? in Twoslash doesn’t work well in Slidev. When adjacent slides are preloaded—or when all slides are preloaded after three seconds— ^? poppers appear, even on slides they don’t belong to. Moreover, once these poppers show up, navigate to other slide pages doesn’t close them unless they were manually closed.

However, It isn't worthwhile to disrupt the current rendering or preload flow just to fix this. Is there a better solution under these constraints?
As for the issue #2202 (which could affect the presentation process), I believe the changes in useNav.ts can resolve that. But for the poppers showing during preload (which results in the slide being cluttered with popups on first load), my current thought is to close them after poping-up with a setTimeout. That said, this problem is generally less critical during a presentation compared to the one discussed in the issue #2202 , since it only happens when slides are initially loaded.

My thoughts might be a bit scattered — want to hear what the community and maintainers think.

preloadRoute(nextRoute.value)
setTimeout(() => {
hideAllPoppers()
}, 150)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This timeout time is too arbitrary. Could we find a better way to do that instead of relying on timeout?\

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It stems from FloatingVue's behavior. when v-popper directives are rendered to the DOM, FloatingVue immediately creates popper instances and shows them based on the :shown='true'... so I think maybe we could implement a custom Shiki transformer to intercept the Twoslash rendering process, and try to transform the code

@elecmonkey elecmonkey force-pushed the fix/slidev-twoslash-popover branch from f6bd3e8 to e381c42 Compare September 28, 2025 04:13
@elecmonkey
Copy link
Contributor Author

Seems like not the cleanest solution, but I think it works beautifully now!

record.mov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slidev twoslash popover keep being open between slides
2 participants