Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fix line numbers incorrectly wrapping inside word-break: break-word parents #61

Merged
merged 1 commit into from
Feb 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pages/code-view/with-line-numbers.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export default function CodeViewPage() {
content={`# Hello World`}
actions={<Button ariaLabel="Copy code" iconName="copy"></Button>}
/>
{/* Wrapping should not be affected by the parent's word-break property. */}
<div style={{ wordBreak: "break-word" }}>
<CodeView
lineNumbers={true}
content={[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((i) => `This is line number #${i + 1}.`).join("\n")}
/>
</div>
</SpaceBetween>
</ScreenshotArea>
);
Expand Down
3 changes: 2 additions & 1 deletion src/code-view/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ $color-background-code-view-dark: #282c34;
}

.line-number {
border-inline-end-color: cs.$color-border-divider-default;
vertical-align: text-top;
white-space: nowrap;
position: sticky;
inset-inline-start: 0;
border-inline-end-width: 1px;
border-inline-end-style: solid;
border-inline-end-color: cs.$color-border-divider-default;
padding-inline-start: cs.$space-static-xs;
padding-inline-end: cs.$space-static-xs;

Expand Down
Loading