Skip to content
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
2 changes: 1 addition & 1 deletion src/code-view/highlight/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export function createHighlight(rules: Ace.HighlightRules): CreateHighlightType
<Fragment key={lineIndex}>
{lineTokens.map((token, tokenIndex) => {
return token.className ? (
<span className={token?.className} key={tokenIndex}>
<span className={token.className} key={tokenIndex}>
{token.value}
</span>
) : (
Expand Down
6 changes: 5 additions & 1 deletion src/code-view/internal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import styles from "./styles.css.js";

const ACE_CLASSES = { light: "ace-cloud_editor", dark: "ace-cloud_editor_dark" };

// Static props objects to avoid recreation on every render.
const REGION_PROPS = { role: "region" } as const;
const NO_REGION_PROPS = {} as const;

type InternalCodeViewProps = CodeViewProps & InternalBaseComponentProps;

// Breaks down the input code for non-highlighted code-view into React
Expand Down Expand Up @@ -47,7 +51,7 @@ export function InternalCodeView({
const containerRef = useRef<HTMLDivElement>(null);
const darkMode = useCurrentMode(containerRef) === "dark";

const regionProps = ariaLabel || ariaLabelledby ? { role: "region" } : {};
const regionProps = ariaLabel || ariaLabelledby ? REGION_PROPS : NO_REGION_PROPS;
const accessibleLineNumbers = lineNumbers && i18nStrings?.lineNumberLabel && i18nStrings?.codeLabel;

// Create tokenized React nodes of the content.
Expand Down
Loading