Skip to content

fix: enable vertical scrolling and fix text-size-adjust on iOS Safari#21

Merged
Huxpro merged 7 commits intomainfrom
Huxpro/fix-code-editor
Mar 18, 2026
Merged

fix: enable vertical scrolling and fix text-size-adjust on iOS Safari#21
Huxpro merged 7 commits intomainfrom
Huxpro/fix-code-editor

Conversation

@Huxpro
Copy link
Copy Markdown
Member

@Huxpro Huxpro commented Mar 17, 2026

Summary

Fixed two issues with the standalone example's code editor:

  1. Vertical scrolling: Changed .shiki overflow from auto to overflow-x: auto; overflow-y: visible to allow the parent .code-view-container to handle vertical scrolling instead of the pre element capturing scroll events.
  2. iOS Safari text adjustment: Added -webkit-text-size-adjust: 100% to prevent iOS Safari from auto-adjusting font size in code blocks.

These changes match the behavior of the rspress code block component and ensure proper scrolling behavior across all platforms.

- Change .shiki overflow from 'auto' to 'overflow-x: auto; overflow-y: visible'
  to allow parent .code-view-container to handle vertical scrolling
- Add -webkit-text-size-adjust: 100% to prevent iOS Safari from auto-adjusting
  font size in code blocks
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 17, 2026

Deploy Preview for lynx-go-web ready!

Name Link
🔨 Latest commit dec4771
🔍 Latest deploy log https://app.netlify.com/projects/lynx-go-web/deploys/69b9f5609bad180008838679
😎 Deploy Preview https://deploy-preview-21--lynx-go-web.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.

Huxpro added 6 commits March 17, 2026 07:38
Add height: 100% to .code-wrap so the descendant .code-view-container
can establish a proper scroll container for vertical overflow.
overflow-x: auto with overflow-y: visible computes to overflow: auto
per CSS spec, making .shiki a nested scroll container that captures
scroll events after React remounts. Use overflow: visible instead and
let .code-view-container handle all scrolling.
Place -webkit-text-size-adjust: 100% on the scroll container itself
so iOS Safari respects it across example switches and React remounts.
…tate

When switching examples, the component remounts and briefly renders a
fallback <pre> with overflow:auto before Shiki highlights the code.
This nested scroll container captured touch/scroll events on iOS Safari,
causing text-size-adjust and scrolling to break after example switching.

Fix by using a consistent rp-codeblock wrapper with a .shiki fallback
<pre> (which inherits overflow:visible from CSS) instead of a bare
<pre style="overflow:auto">.
iOS Safari's text-size-adjust algorithm runs at the document level.
Setting it only on child elements (scroll containers, .shiki, etc.)
is unreliable — iOS can ignore those declarations and re-apply font
scaling for text inside scroll containers.

Setting it on html/body ensures it takes effect before first paint
and prevents iOS from auto-scaling code text in the editor panel.
Shiki sets --shiki-dark-bg only as an inline style on <pre class="shiki">,
so it doesn't cascade up to ancestor elements like .code-wrap or
.code-view-container. Those containers fell back to --semi-color-bg-1
(a Semi UI dark color) instead of the github-dark background #24292e,
causing a visible color mismatch in dark mode.

Fix by defining --shiki-dark-bg and --rp-code-block-bg at the html
element level for dark mode, so they cascade to all layout containers.
Also corrects the light-mode default to #fff to match github-light.
@Huxpro Huxpro merged commit 38c0a3a into main Mar 18, 2026
7 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.

1 participant