fix(agents): dismiss the image preview on outside click (#8159)

The agent image preview only closed with Esc or its Close button. It now also closes on a click outside the dialog; clicks inside keep it open.

Co-authored-by: chiyanking <[email protected]>
Цей коміт міститься в:
tongkangwangтаchiyanking authored and GitHub committed 2026-12-05 13:37:14 +08:00
1 джерело 6b94744df3
коміт 588d1d17aa
2 files changed
+11

No files matched your search

+1
Переглянути файл
@@ -20,6 +20,7 @@ export function ImagePreview({ image, onClose }: { image: AgentImage | null; onC
<Dialog
open={image !== null}
onClose={onClose}
dismissOnBackdrop
title={image?.name ?? tx("Image")}
width="min(90vw, 1000px)"
buttons={[
+10
Переглянути файл
@@ -53,6 +53,16 @@ it("copies from the full preview and confirms success without closing it", async
]);
});
it("closes the preview when clicking outside it but not inside", () => {
render(<ImageStrip images={[image]} />);
fireEvent.click(screen.getByRole("img"));
const dialog = screen.getByRole("dialog", { name: "preview.png" });
fireEvent.pointerDown(dialog.querySelector("img")!);
expect(screen.getByRole("dialog")).toBeInTheDocument();
fireEvent.pointerDown(dialog.parentElement!);
expect(screen.queryByRole("dialog")).not.toBeInTheDocument();
});
it("leaves the copy action available for retry after native clipboard failure", async () => {
mocks.write.mockRejectedValueOnce(new Error("denied"));
render(<ImageStrip images={[image]} />);