Skip to content

Commit c77e6df

Browse files
committed
Improves scroll behaviour for the code block
1 parent 5a5ee25 commit c77e6df

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

apps/webapp/app/components/code/CodeBlock.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,10 @@ export const CodeBlock = forwardRef<HTMLDivElement, CodeBlockProps>(
265265
return (
266266
<>
267267
<div
268-
className={cn("relative overflow-hidden rounded-md border border-grid-bright", className)}
268+
className={cn(
269+
"relative flex flex-col overflow-hidden rounded-md border border-grid-bright",
270+
className
271+
)}
269272
style={{
270273
backgroundColor: theme.plain.backgroundColor,
271274
}}
@@ -355,9 +358,8 @@ export const CodeBlock = forwardRef<HTMLDivElement, CodeBlockProps>(
355358
<div
356359
dir="ltr"
357360
className={cn(
358-
"px-2 py-3 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600",
359-
!isWrapped && "overflow-x-auto",
360-
isWrapped && "overflow-y-auto"
361+
"min-h-0 flex-1 px-2 py-3 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600",
362+
"overflow-auto"
361363
)}
362364
style={{
363365
maxHeight,
@@ -490,9 +492,9 @@ function HighlightCode({
490492
}, []);
491493

492494
const containerClasses = cn(
493-
"px-3 py-3 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600",
494-
!isWrapped && "overflow-x-auto",
495-
isWrapped && "overflow-y-auto",
495+
"min-h-0 flex-1 px-3 py-3 scrollbar-thin scrollbar-track-transparent scrollbar-thumb-charcoal-600",
496+
!isWrapped && "overflow-auto",
497+
isWrapped && "overflow-auto",
496498
className
497499
);
498500

0 commit comments

Comments
 (0)