fix(rendering): prevent copy button from scrolling with code block content#5118
Open
HUQIANTAO wants to merge 1 commit into
Open
fix(rendering): prevent copy button from scrolling with code block content#5118HUQIANTAO wants to merge 1 commit into
HUQIANTAO wants to merge 1 commit into
Conversation
…ntent The copy button in code blocks uses position: absolute relative to the .code-block wrapper. When the inner <pre> overflows horizontally, the wrapper expands to fit the full scroll width, causing the button to drift off-screen with the content. Adding overflow: hidden to .code-block constrains the wrapper to its parent's width so the absolutely-positioned button stays pinned at the top-right corner of the visible area. The inner <pre> retains its own overflow: auto for independent scrolling. Fixes esengine#5096
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a code block contains long lines that trigger horizontal scrolling, the copy button in the top-right corner drifts off-screen with the content instead of staying pinned to the visible area.
Reproduction (Issue #5096):
Root Cause
The DOM structure is:
The
.code-blockwrapper hasposition: relativebut no explicit width constraint. When the inner<pre>overflows horizontally, the wrapper expands to match the full scroll width. The absolutely-positioned copy button is then anchored to the right edge of this expanded container — which is off-screen.Fix
Add
overflow: hiddento.code-block. This constrains the wrapper to its parent's width, so the absolutely-positioned button stays pinned at the top-right corner of the visible area. The inner<pre>retains its ownoverflow: autofor independent scrolling.Single-line change in
desktop/frontend/src/styles.css:Testing