fix(webui): retain content ownership of dialog exit lifetime
This commit is contained in:
1 parent
ce89f7caf7
commit
3ff76cd808
2 files changed
+10
-4
No files matched your search
@@ -36,13 +36,17 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
|
|||||||
// positioning wrapper; otherwise the wrapper unmounts before the exit finishes.
|
// positioning wrapper; otherwise the wrapper unmounts before the exit finishes.
|
||||||
// Auto margins center/bottom-align surfaces when they fit, but collapse to zero
|
// 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.
|
// 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<
|
const DialogPositionedContent = React.forwardRef<
|
||||||
React.ElementRef<typeof DialogPrimitive.Content>,
|
React.ElementRef<typeof DialogPrimitive.Content>,
|
||||||
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
|
||||||
positionerStyle?: React.CSSProperties;
|
positionerStyle?: React.CSSProperties;
|
||||||
placement?: "center" | "bottom";
|
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={{
|
<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)",
|
top: "var(--app-viewport-top, 0px)",
|
||||||
height: "var(--app-viewport-height, 100%)",
|
height: "var(--app-viewport-height, 100%)",
|
||||||
@@ -51,6 +55,7 @@ const DialogPositionedContent = React.forwardRef<
|
|||||||
}}>
|
}}>
|
||||||
<DialogPrimitive.Content ref={ref} {...props} />
|
<DialogPrimitive.Content ref={ref} {...props} />
|
||||||
</div>
|
</div>
|
||||||
|
</DialogOverlay>
|
||||||
));
|
));
|
||||||
DialogPositionedContent.displayName = "DialogPositionedContent";
|
DialogPositionedContent.displayName = "DialogPositionedContent";
|
||||||
|
|
||||||
@@ -99,10 +104,10 @@ const DialogContent = React.forwardRef<
|
|||||||
}, [ref]);
|
}, [ref]);
|
||||||
return (
|
return (
|
||||||
<DialogPortal>
|
<DialogPortal>
|
||||||
<DialogOverlay className={overlayClassName}>
|
|
||||||
<DialogPositionedContent
|
<DialogPositionedContent
|
||||||
positionerStyle={layout}
|
positionerStyle={layout}
|
||||||
placement={placement}
|
placement={placement}
|
||||||
|
overlayClassName={overlayClassName}
|
||||||
ref={contentRef}
|
ref={contentRef}
|
||||||
onOpenAutoFocus={(event) => {
|
onOpenAutoFocus={(event) => {
|
||||||
if (onOpenAutoFocus) onOpenAutoFocus(event);
|
if (onOpenAutoFocus) onOpenAutoFocus(event);
|
||||||
@@ -131,7 +136,6 @@ const DialogContent = React.forwardRef<
|
|||||||
</DialogPrimitive.Close>
|
</DialogPrimitive.Close>
|
||||||
) : null}
|
) : null}
|
||||||
</DialogPositionedContent>
|
</DialogPositionedContent>
|
||||||
</DialogOverlay>
|
|
||||||
</DialogPortal>
|
</DialogPortal>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1022,7 +1022,9 @@ describe("remote instance UX", () => {
|
|||||||
fireEvent.submit(address.closest("form")!);
|
fireEvent.submit(address.closest("form")!);
|
||||||
const alert = await screen.findByRole("alert");
|
const alert = await screen.findByRole("alert");
|
||||||
expect(alert).toHaveTextContent(i18n.t("remote.errors.ssh_agent_refused"));
|
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");
|
expect(address).toHaveValue("ubuntu@example.test");
|
||||||
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
|
fireEvent.click(screen.getByRole("button", { name: "Connection options" }));
|
||||||
expect(screen.getByRole("spinbutton", { name: "SSH port" })).toHaveValue(2222);
|
expect(screen.getByRole("spinbutton", { name: "SSH port" })).toHaveValue(2222);
|
||||||
|
|||||||
Reference in new issue
Block a user