From 3ff76cd808ecbe5bf15e23c16226f30da84bd014 Mon Sep 17 00:00:00 2001 From: Xubin Ren <52506698+Re-bin@users.noreply.github.com> Date: Sun, 4 Oct 2026 19:17:46 +0800 Subject: [PATCH] fix(webui): retain content ownership of dialog exit lifetime --- webui/src/components/ui/dialog.tsx | 10 +++++++--- webui/src/tests/remote-instances.test.tsx | 4 +++- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/webui/src/components/ui/dialog.tsx b/webui/src/components/ui/dialog.tsx index 98fd1557c..c093791e1 100644 --- a/webui/src/components/ui/dialog.tsx +++ b/webui/src/components/ui/dialog.tsx @@ -36,13 +36,17 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; // positioning wrapper; otherwise the wrapper unmounts before the exit finishes. // Auto margins center/bottom-align surfaces when they fit, but collapse to zero // when they overflow so the beginning of a tall dialog remains scrollable. +// The overlay stays mounted for the content's presence lifetime, so its own +// fade cannot remove the content before its exit cleanup/handoff completes. const DialogPositionedContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { positionerStyle?: React.CSSProperties; placement?: "center" | "bottom"; + overlayClassName?: string; } ->(({ positionerStyle, placement, ...props }, ref) => ( +>(({ positionerStyle, placement, overlayClassName, ...props }, ref) => ( +
+
)); DialogPositionedContent.displayName = "DialogPositionedContent"; @@ -99,10 +104,10 @@ const DialogContent = React.forwardRef< }, [ref]); return ( - { if (onOpenAutoFocus) onOpenAutoFocus(event); @@ -131,7 +136,6 @@ const DialogContent = React.forwardRef< ) : null} - ); }); diff --git a/webui/src/tests/remote-instances.test.tsx b/webui/src/tests/remote-instances.test.tsx index 75e0fd9be..68f8a3e2d 100644 --- a/webui/src/tests/remote-instances.test.tsx +++ b/webui/src/tests/remote-instances.test.tsx @@ -1022,7 +1022,9 @@ describe("remote instance UX", () => { fireEvent.submit(address.closest("form")!); const alert = await screen.findByRole("alert"); expect(alert).toHaveTextContent(i18n.t("remote.errors.ssh_agent_refused")); - expect(alert.closest(".overflow-y-auto")).toBeNull(); + // Errors stay outside the form's field scroller. The outer dialog frame + // may itself scroll when a mobile keyboard leaves less room than the form. + expect(address.closest("form")!.querySelector(".overflow-y-auto")).not.toContainElement(alert); expect(address).toHaveValue("ubuntu@example.test"); fireEvent.click(screen.getByRole("button", { name: "Connection options" })); expect(screen.getByRole("spinbutton", { name: "SSH port" })).toHaveValue(2222);