Skip to content

Conversation

@dahlia
Copy link
Contributor

@dahlia dahlia commented Dec 13, 2025

Description

Fix scroll blocking issue on mobile viewports when pages contain Twoslash type hint popups (// ^? queries).

The original issue hypothesized this was a “scroll chaining” problem from overflow-y: auto, but investigation revealed a different root cause: multiple popper elements with position: absolute and transforms were affecting the browser's wheel scroll calculations, causing scroll to stop prematurely (at ~96% of max scroll instead of 100%).

The fix adds content-visibility: auto to popper elements, which tells the browser to optimize rendering of off-screen content and prevents them from interfering with scroll calculations.

Linked issues

Fixes #1234.

Additional context

Testing performed

  • Tested on https://optique.dev/why (a page with multiple Twoslash type hints)
  • Mobile viewport emulation (390×844, iPhone 12 Pro)
  • Before fix: Scroll stopped at 11544px (96%), with 56 backward scroll events detected
  • After fix: Scroll reaches 12023px (100%), with 0 backward scroll events

Why overscroll-behavior: contain didn't work

The issue wasn't scroll chaining from inner scrollable elements—it was the popper elements affecting the browser's scroll boundary calculation itself.

Add content-visibility: auto to popper elements to prevent them from
affecting browser wheel scroll calculations. This fixes an issue where
scrolling would stop prematurely on pages with Twoslash type hints.

Closes shikijs#1234
@netlify
Copy link

netlify bot commented Dec 13, 2025

Deploy Preview for shiki-next ready!

Name Link
🔨 Latest commit f8f63e0
🔍 Latest deploy log https://app.netlify.com/projects/shiki-next/deploys/693d9c8638968b00087bdd5e
😎 Deploy Preview https://deploy-preview-1235--shiki-next.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.

@netlify
Copy link

netlify bot commented Dec 13, 2025

Deploy Preview for shiki-matsu ready!

Name Link
🔨 Latest commit f8f63e0
🔍 Latest deploy log https://app.netlify.com/projects/shiki-matsu/deploys/693d9c861275ba000821da33
😎 Deploy Preview https://deploy-preview-1235--shiki-matsu.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.

@codecov
Copy link

codecov bot commented Dec 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.21%. Comparing base (a0b7304) to head (f8f63e0).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1235   +/-   ##
=======================================
  Coverage   95.21%   95.21%           
=======================================
  Files          92       92           
  Lines        7936     7936           
  Branches     1694     1694           
=======================================
  Hits         7556     7556           
  Misses        374      374           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dahlia
Copy link
Contributor Author

dahlia commented Dec 13, 2025

The CI failure on test (22.x, windows-latest) seems unrelated to this PR.

The failing test (injections-side-effects vue) appears to be a snapshot mismatch caused by ANSI escape codes ([7m, [27m) appearing in the output on Windows. This looks like a pre-existing flaky test issue in the core package, rather than something caused by the CSS-only change in this PR.

@antfu antfu changed the title Fix scroll blocking on mobile viewports in vitepress-twoslash fix(vitepress-twoslash): scroll blocking on mobile viewports Dec 14, 2025
@antfu antfu merged commit 8e9314f into shikijs:main Dec 14, 2025
13 of 14 checks passed
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.

vitepress-twoslash: Mobile scroll chaining issue with persistent type hint popups

2 participants