Skip to content

Commit 316c765

Browse files
authored
fix(toc): prevent right ToC from shrinking; enforce 250px min width (#14872)
fix(toc): prevent right ToC from shrinking; enforce 250px min width Context - Right-hand ToC width (set to 250px) was shrinking in the flex layout between the 'toc' breakpoint (1490px) and the ultra-wide breakpoint (2057px), especially visible when Session Replay UI alters available width. - Additionally, some pages had extremely long, unbroken content inside code blocks (e.g., long URLs/paths/tokens). When code options changed, these long lines could expand the content column and indirectly squeeze the ToC. Changes - ToC: Make the <aside> a non-shrinking flex item and enforce a minimum width. - Updated `src/components/docPage/index.tsx` ToC aside classes from `hidden toc:block w-[250px]` to `hidden toc:block flex-none w-[250px] min-w-[250px]`. - Code wrapping: Wrap long lines inside code blocks so they don’t expand layout. - Updated `src/components/codeBlock/code-blocks.module.scss` to apply: - `white-space: pre-wrap;`, `word-break: break-word;`, `overflow-wrap: anywhere;` on `pre` and `pre[class*='language-']`. - Same wrapping rules on `.code-line` to preserve highlight behavior. - `max-width: 100%;` and `tab-size: 2;` on `pre`. - Main content flex: Allow the main content column to shrink within the flex layout. - Added `min-w-0` to the `#doc-content` container in `src/components/docPage/index.tsx`. Result - When the ToC is visible, it remains a fixed 250px and does not compress due to layout shifts. - Long code no longer forces the content area to expand; lines wrap within the available width. - Existing responsive behavior remains unchanged: ToC hidden below the `toc` breakpoint; pinned/fixed layout ≥2057px. Files - `src/components/docPage/index.tsx` - `src/components/codeBlock/code-blocks.module.scss`
1 parent 74d491b commit 316c765

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

src/components/codeBlock/code-blocks.module.scss

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
border-radius: 0 0 6px 6px;
99
margin-top: 0;
1010
margin-bottom: 0;
11+
/* Wrap overly long lines so blocks never expand layout */
12+
white-space: pre-wrap;
13+
word-break: break-word;
14+
overflow-wrap: anywhere;
15+
max-width: 100%;
16+
tab-size: 2;
1117
}
1218

1319
code[class*='language-'],
@@ -20,6 +26,10 @@
2026
border: 1px solid var(--accent-11);
2127
border-radius: 6px;
2228
margin: 0;
29+
/* Ensure syntax-highlighted pre behaves like above */
30+
white-space: pre-wrap;
31+
word-break: break-word;
32+
overflow-wrap: anywhere;
2333
}
2434

2535
/**
@@ -66,6 +76,10 @@
6676
float: left;
6777
min-width: 100%;
6878
box-sizing: border-box;
79+
/* Allow wrapping inside each highlighted line */
80+
white-space: pre-wrap;
81+
word-break: break-word;
82+
overflow-wrap: anywhere;
6983
// Set placeholder for highlight accent border color to transparent
7084
border-left: 4px solid rgba(0, 0, 0, 0);
7185

src/components/docPage/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@ export function DocPage({
7676
'prose-blockquote:font-normal prose-blockquote:border-l-[3px] prose-em:font-normal prose-blockquote:text-[var(--gray-12)]',
7777
'prose-img:my-2',
7878
'prose-strong:text-[var(--gray-12)]',
79-
fullWidth ? 'max-w-none w-full' : 'w-full',
79+
// Allow flex item to shrink within layout; prevents long content from
80+
// forcing the main column to grow and squeezing the ToC
81+
fullWidth ? 'max-w-none w-full min-w-0' : 'w-full min-w-0',
8082
].join(' ')}
8183
id="doc-content"
8284
>
@@ -117,7 +119,7 @@ export function DocPage({
117119
{hasToc && (
118120
<aside
119121
data-layout-anchor="right"
120-
className="sticky h-[calc(100vh-var(--header-height))] top-[var(--header-height)] overflow-y-auto hidden toc:block w-[250px]"
122+
className="sticky h-[calc(100vh-var(--header-height))] top-[var(--header-height)] overflow-y-auto hidden toc:block flex-none w-[250px] min-w-[250px]"
121123
>
122124
<div className="sidebar">
123125
<SidebarTableOfContents />

0 commit comments

Comments
 (0)