Skip to content

Commit 416d08b

Browse files
authored
fix: Fix line numbers incorrectly wrapping inside word-break: break-word parents (#61)
1 parent 1055d7b commit 416d08b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-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: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ $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+
white-space: nowrap;
4949
position: sticky;
5050
inset-inline-start: 0;
5151
border-inline-end-width: 1px;
5252
border-inline-end-style: solid;
53+
border-inline-end-color: cs.$color-border-divider-default;
5354
padding-inline-start: cs.$space-static-xs;
5455
padding-inline-end: cs.$space-static-xs;
5556

0 commit comments

Comments
 (0)