Skip to content
Open
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
19 changes: 19 additions & 0 deletions app/src/components/Actions/Actions.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,25 @@ describe("Action component", () => {
expect(screen.queryByLabelText("Run code")).toBeNull();
});

it("switches rendered html cells back to edit mode on Escape", () => {
const cell = create(parser_pb.CellSchema, {
refId: "cell-html-escape",
kind: parser_pb.CellKind.CODE,
languageId: "html",
outputs: [],
metadata: {},
value: "<div><strong>Hello HTML</strong></div>",
});
const stub = new StubCellData(cell);

render(<Action cellData={stub as unknown as CellData} isFirst={false} />);

const rendered = screen.getByTestId("html-rendered");
fireEvent.keyDown(rendered, { key: "Escape" });

expect(screen.getByTestId("html-editor")).toBeTruthy();
});

it("shows browser/sandbox runner selector for javascript cells", () => {
const cell = create(parser_pb.CellSchema, {
refId: "cell-runner-select",
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/Actions/HtmlCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const HtmlCell = memo(
if (event.target !== event.currentTarget) {
return;
}
if (event.key === "Enter" || event.key === " ") {
if (event.key === "Enter" || event.key === " " || event.key === "Escape") {
event.preventDefault();
setRendered(false);
}
Expand Down Expand Up @@ -146,7 +146,7 @@ const HtmlCell = memo(
onKeyDown={handleRenderedKeyDown}
tabIndex={0}
role="button"
aria-label="Press Enter to edit HTML"
aria-label="Press Enter, Space, or Escape to edit HTML"
data-testid="html-rendered"
>
<div className="flex items-center justify-between border-b border-nb-border bg-nb-surface-2 px-3 py-2">
Expand Down
Loading