Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix(frontend): add readonly code button aria-labels and tidy toggle state (#10112)

Kiran Gadhavef37affe29c9e
diff --git a/frontend/src/components/editor/code/readonly-python-code.tsx b/frontend/src/components/editor/code/readonly-python-code.tsx
index 3f4db1a824..b5b6c319a7 100644
--- a/frontend/src/components/editor/code/readonly-python-code.tsx
+++ b/frontend/src/components/editor/code/readonly-python-code.tsx
@@ -76,7 +76,7 @@ export const ReadonlyCode = memo(
language = "python",
...rest
} = props;
- const [hideCode, setHideCode] = useState(initiallyHideCode);
+ const [hideCode, setHideCode] = useState(!!initiallyHideCode);
const extensions = useMemo(
() => [
@@ -99,8 +99,8 @@ export const ReadonlyCode = memo(
{insertNewCell && <InsertNewCell code={code} />}
{showHideCode && (
<ToggleCodeButton
- hidden={hideCode ?? false}
- onClick={() => setHideCode(!hideCode)}
+ hidden={hideCode}
+ onClick={() => setHideCode((prev) => !prev)}
/>
)}
</div>
@@ -128,7 +128,13 @@ const CopyButton = (props: { text: string }) => {
return (
<Tooltip content="Copy code" usePortal={false}>
- <Button onClick={copy} size="xs" className="py-0" variant="secondary">
+ <Button
+ onClick={copy}
+ size="xs"
+ className="py-0"
+ variant="secondary"
+ aria-label="Copy code"
+ >
<CopyIcon size={14} strokeWidth={1.5} />
</Button>
</Tooltip>
@@ -143,6 +149,7 @@ const ToggleCodeButton = (props: { hidden: boolean; onClick: () => void }) => {
>
<Button
onClick={props.onClick}
+ aria-label={props.hidden ? "Show code" : "Hide code"}
size="xs"
className="py-0"
variant="secondary"
@@ -171,6 +178,7 @@ const InsertNewCell = (props: { code: string }) => {
size="xs"
className="py-0"
variant="secondary"
+ aria-label="Add code to notebook"
>
<PlusIcon size={14} strokeWidth={1.5} />
</Button>