fix(ui): defer showModal until dialog is connected to DOM

This commit is contained in:
Nickmopen
2026-05-03 08:41:56 -05:00
committed by Peter Steinberger
parent d6900ee500
commit e8227fd7b3
2 changed files with 11 additions and 1 deletions

View File

@@ -100,6 +100,8 @@ describe("renderSkills", () => {
it("opens detail dialogs and routes ClawHub actions", async () => {
const container = document.createElement("div");
document.body.append(container);
dialogRestores.push(() => container.remove());
const onDetailClose = vi.fn();
const showModal = vi.fn(function (this: HTMLDialogElement) {
this.setAttribute("open", "");

View File

@@ -28,7 +28,15 @@ function showDialogWhenClosed(el?: Element) {
if (!(el instanceof HTMLDialogElement) || el.open) {
return;
}
el.showModal();
if (el.isConnected) {
el.showModal();
} else {
queueMicrotask(() => {
if (el.isConnected && !el.open) {
el.showModal();
}
});
}
}
export type SkillsStatusFilter = "all" | "ready" | "needs-setup" | "disabled";