Skip to content

fix(theme/CodeBlock): preserve background when scrolling horizontally - #3634

Merged
SoonIter merged 1 commit into
web-infra-dev:mainfrom
ruibaby:fix/code-block-overflow-background
Aug 27, 2026
Merged

fix(theme/CodeBlock): preserve background when scrolling horizontally#3634
SoonIter merged 1 commit into
web-infra-dev:mainfrom
ruibaby:fix/code-block-overflow-background

Conversation

@ruibaby

@ruibaby ruibaby commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR fixes code block backgrounds becoming white when horizontally scrolling overflow with a dark Shiki theme.

Before, the <pre> element stayed at the visible container width while the nested <code> element expanded to the content width, exposing the surrounding light background. After, the <pre> element covers the full scrollable width while preserving wrapped code behavior.

Related Issue

N/A

Screenshots

Before After
image image

Checklist

  • Tests updated (or not required).
  • Documentation updated (or not required).

Copilot AI lite review requested due to automatic review settings August 27, 2026 10:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts the default theme’s CodeBlock styling so Shiki-rendered code blocks keep their background color visible across the full horizontally scrollable width (preventing the “white gap” when long lines overflow).

Changes:

  • Make the <pre> element expand to the scrollable content width by using width: fit-content with min-width: 100%.
  • Preserve existing behavior where wrapped code still occupies at least the container width.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@SoonIter SoonIter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

thanks ~

@SoonIter
SoonIter merged commit 8764f37 into web-infra-dev:main Aug 27, 2026
6 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.

3 participants