Skip to content

Commit 62fb506

Browse files
committed
Keep non-table format.
1 parent c219612 commit 62fb506

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function CodeViewPage() {
2121
<div style={{ wordBreak: "break-word" }}>
2222
<CodeView
2323
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")}
24+
content={[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((i) => `This is line number #${i}.`).join("\n")}
2525
/>
2626
</div>
2727
</SpaceBetween>

src/code-view/internal.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function InternalCodeView({
6666
>
6767
<div className={styles["scroll-container"]} ref={containerRef}>
6868
<table
69-
role={lineNumbers ? "table" : "presentation"}
69+
role="presentation"
7070
className={clsx(
7171
styles["code-table"],
7272
actions && styles["code-table-with-actions"],
@@ -77,26 +77,19 @@ export function InternalCodeView({
7777
<col style={{ width: 1 } /* shrink to fit content */} />
7878
<col style={{ width: "auto" }} />
7979
</colgroup>
80-
{lineNumbers && (
81-
<thead className={styles["table-header"]}>
82-
<tr>
83-
<th>Row number</th>
84-
<th>Content</th>
85-
</tr>
86-
</thead>
87-
)}
8880
<tbody>
8981
{Children.map(codeElement.props.children, (child, index) => {
9082
return (
9183
<tr key={index}>
9284
{lineNumbers && (
93-
<td className={clsx(styles["line-number"], styles.unselectable)}>
85+
<td className={clsx(styles["line-number"], styles.unselectable)} aria-hidden={true}>
9486
<Box variant="code" color="text-status-inactive" fontSize="body-m">
9587
{index + 1}
9688
</Box>
9789
</td>
9890
)}
9991
<td className={styles["code-line"]}>
92+
<span className={styles["screenreader-only"]}>Line {index + 1} </span>
10093
<Box variant="code" fontSize="body-m">
10194
<span
10295
className={clsx(

src/code-view/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ $color-background-code-view-dark: #282c34;
4343
padding-inline-end: cs.$space-static-xxl;
4444
}
4545

46-
.table-header {
46+
.screenreader-only {
4747
position: absolute;
4848
inset-block-start: -9999px;
4949
inset-inline-start: -9999px;

0 commit comments

Comments
 (0)