Skip to content

Commit 00941dd

Browse files
committed
fix: Fix line numbers incorrectly wrapping inside word-break: break-word parents
1 parent 1055d7b commit 00941dd

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

pages/code-view/with-line-numbers.page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ export default function CodeViewPage() {
1717
content={`# Hello World`}
1818
actions={<Button ariaLabel="Copy code" iconName="copy"></Button>}
1919
/>
20+
{/* Wrapping should not be affected by the parent's word-break property. */}
21+
<div style={{ wordBreak: "break-word" }}>
22+
<CodeView
23+
lineNumbers={true}
24+
content={[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((i) => `This is line number #${i + 1}.`).join("\n")}
25+
/>
26+
</div>
2027
</SpaceBetween>
2128
</ScreenshotArea>
2229
);

src/code-view/styles.scss

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ $color-background-code-view-dark: #282c34;
4444
}
4545

4646
.line-number {
47-
border-inline-end-color: cs.$color-border-divider-default;
4847
vertical-align: text-top;
48+
text-align: right;
49+
white-space: nowrap;
4950
position: sticky;
5051
inset-inline-start: 0;
5152
border-inline-end-width: 1px;
5253
border-inline-end-style: solid;
54+
border-inline-end-color: cs.$color-border-divider-default;
5355
padding-inline-start: cs.$space-static-xs;
5456
padding-inline-end: cs.$space-static-xs;
5557

0 commit comments

Comments
 (0)