fix(webui): retain content ownership of dialog exit lifetime

This commit is contained in:
Xubin Ren committed 2026-10-04 20:14:21 +08:00
1 parent ce89f7caf7
commit 3ff76cd808
2 files changed
+10 -4

No files matched your search

+7 -3
View File
@@ -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<typeof DialogPrimitive.Content>,
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
positionerStyle?: React.CSSProperties;
placement?: "center" | "bottom";
overlayClassName?: string;
}
>(({ positionerStyle, placement, ...props }, ref) => (
>(({ positionerStyle, placement, overlayClassName, ...props }, ref) => (
<DialogOverlay forceMount className={overlayClassName}>
<div className={cn("fixed inset-0 z-50 flex items-start justify-center overflow-y-auto overscroll-contain", placement !== "bottom" && "p-4")} style={{
top: "var(--app-viewport-top, 0px)",
height: "var(--app-viewport-height, 100%)",
@@ -51,6 +55,7 @@ const DialogPositionedContent = React.forwardRef<
}}>
<DialogPrimitive.Content ref={ref} {...props} />
</div>
</DialogOverlay>
));
DialogPositionedContent.displayName = "DialogPositionedContent";
@@ -99,10 +104,10 @@ const DialogContent = React.forwardRef<
}, [ref]);
return (
<DialogPortal>
<DialogOverlay className={overlayClassName}>
<DialogPositionedContent
positionerStyle={layout}
placement={placement}
overlayClassName={overlayClassName}
ref={contentRef}
onOpenAutoFocus={(event) => {
if (onOpenAutoFocus) onOpenAutoFocus(event);
@@ -131,7 +136,6 @@ const DialogContent = React.forwardRef<
</DialogPrimitive.Close>
) : null}
</DialogPositionedContent>
</DialogOverlay>
</DialogPortal>
);
});
+3 -1
View File
@@ -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);