GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(web): pressing Escape in the PR markdown editor keeps the right p… · patroza/t3code@a8f708d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • apps/web/src/components/pullRequest
    • PullRequestMarkdownEditor.browser.test.tsx
    • PullRequestMarkdownEditor.tsx
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎apps/web/src/components/pullRequest/PullRequestMarkdownEditor.browser.test.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestMarkdownEditor.browser.test.tsx
+42Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { act, render, type Screen } from "../../../test/render";
22
import { AuthSourceControlWriteScope, EnvironmentId, ProjectId } from "@t3tools/contracts";
3+
import { useState } from "react";
34
import { expect, it, vi } from "vite-plus/test";
45
import { page, userEvent } from "vite-plus/test/browser";
56

@@ -49,6 +50,7 @@ vi.mock(import("~/state/pullRequests"), async (original) => ({
4950
}),
5051
}));
5152

53+
import { RightPanelSheet } from "../RightPanelSheet";
5254
import { PullRequestMarkdownEditor } from "./PullRequestMarkdownEditor";
5355

5456
const secondary = EnvironmentId.make("secondary");
@@ -143,3 +145,43 @@ it("completes @mentions and !references on Enter, and Escape closes the list unt
143145
expect(onCancel).not.toHaveBeenCalled();
144146
expect(onSave).not.toHaveBeenCalled();
145147
});
148+
149+
it("Escape cancels the edit without closing the right panel sheet", async () => {
150+
setup();
151+
permissions.allowed.add(secondary);
152+
const onCloseSheet = vi.fn();
153+
function EditableComment() {
154+
const [editing, setEditing] = useState(true);
155+
if (!editing) return <p>Original description</p>;
156+
return (
157+
<PullRequestMarkdownEditor
158+
value="Original description"
159+
cwd="/repo"
160+
environmentId={secondary}
161+
completionScope={null}
162+
label="Pull request description"
163+
saving={false}
164+
onSave={onSave}
165+
onCancel={() => {
166+
onCancel();
167+
setEditing(false);
168+
}}
169+
/>
170+
);
171+
}
172+
await using _screen = await render(
173+
<RightPanelSheet animationDurationMs={0} open onClose={onCloseSheet}>
174+
<EditableComment />
175+
</RightPanelSheet>,
176+
);
177+
const textarea = page.getByRole("textbox", { name: "Pull request description" });
178+
await expect.element(textarea).toHaveFocus();
179+
180+
await userEvent.keyboard("{Escape}");
181+
await expect.element(textarea).not.toBeInTheDocument();
182+
expect(onCancel).toHaveBeenCalledTimes(1);
183+
expect(onCloseSheet).not.toHaveBeenCalled();
184+
185+
await userEvent.keyboard("{Escape}");
186+
expect(onCloseSheet).toHaveBeenCalledTimes(1);
187+
});
Collapse file

‎apps/web/src/components/pullRequest/PullRequestMarkdownEditor.tsx‎

Copy file name to clipboardExpand all lines: apps/web/src/components/pullRequest/PullRequestMarkdownEditor.tsx
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export function PullRequestMarkdownEditor({
7979
}
8080
if (event.key !== "Escape" || saving) return;
8181
event.preventDefault();
82+
event.stopPropagation();
8283
onCancel();
8384
}}
8485
>

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.