Skip to content

fix: enable horizontal scrollbar in code blocks#488

Draft
laileni-aws wants to merge 2 commits into
aws:mainfrom
laileni-aws:fix/code-block-horizontal-scrollbar
Draft

fix: enable horizontal scrollbar in code blocks#488
laileni-aws wants to merge 2 commits into
aws:mainfrom
laileni-aws:fix/code-block-horizontal-scrollbar

Conversation

@laileni-aws

Copy link
Copy Markdown
Contributor

Problem

Code blocks in the chat window have no horizontal scrollbar. Long lines (e.g. multi-flag CLI commands, wide table output) are truncated at the panel edge with no way to view the hidden content.

Solution

Two CSS issues compound to make horizontal scrolling impossible:

  1. Webkit scrollbar rule hides horizontal tracks: _main-container.scss set ::-webkit-scrollbar:horizontal { width: 0px; height: 0px; } which makes the scrollbar invisible in webkit-based browsers (Chrome, Edge, and the JCEF browser embedded in JetBrains IDEs). Fixed by restoring a visible height: 4px track.

  2. Flex-child overflow: The pre element inside .mynah-syntax-highlighter (a flex-column container with max-width: 100%) lacked min-width: 0, which is the classic fix to prevent flex children from expanding beyond their parent. Without it, the pre pushes beyond the parent's constraint instead of scrolling internally. Added min-width: 0 so overflow-x: auto on pre works as intended.

What changes for users

Scenario Before After
Long code line in response Truncated, no scroll Horizontal scrollbar appears, user can scroll
Short code line in response No scrollbar No scrollbar (unchanged, overflow-x: auto only shows when needed)
Narrow viewport (< breakpoint) pre-wrap wraps lines Same (responsive behavior unchanged)

Testing

  • npm run build compiles without errors
  • Visual verification: the pre element with long content now shows a thin (4px) horizontal scrollbar track in webkit browsers
  • Responsive pre-wrap at narrow viewport widths still works (the @media (max-width) rules are untouched)

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Code blocks with long lines were impossible to scroll horizontally
because two CSS rules conspired to hide the scrollbar:

1. The global webkit-scrollbar:horizontal rule set width/height to 0px,
   making the scrollbar invisible even though `pre` had `overflow-x: auto`.
2. The `pre` element inside a flex-column parent could expand beyond the
   parent's constraint without `min-width: 0`, preventing internal scroll.

Fix: give `pre` the classic flex-child overflow fix (`min-width: 0`) and
restore horizontal scrollbar visibility with a 4px track height.
Pre-existing lint violation that blocked the pre-push hook.
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