Skip to content

armgit / qm

Public Imported from GitHub
0

Multiplayer agent harness for work.

Fix icon clicks lost during background redraws (#1364)

Joshua France7013d2d81996
diff --git a/plugins/web-ui/src/shell.css b/plugins/web-ui/src/shell.css
index 017a7efb4..a8562623c 100644
--- a/plugins/web-ui/src/shell.css
+++ b/plugins/web-ui/src/shell.css
@@ -251,6 +251,7 @@ body.resizing-sidebar {
.icon {
display: block;
flex-shrink: 0;
+ pointer-events: none;
}
.nav {
diff --git a/plugins/web-ui/test/icon-pointer-events.test.ts b/plugins/web-ui/test/icon-pointer-events.test.ts
new file mode 100644
index 000000000..b6068d947
--- /dev/null
+++ b/plugins/web-ui/test/icon-pointer-events.test.ts
@@ -0,0 +1,52 @@
+import assert from "node:assert/strict";
+import { readFileSync } from "node:fs";
+import test from "node:test";
+import { JSDOM } from "jsdom";
+
+const dom = new JSDOM("<!doctype html><body></body>", { url: "http://localhost/" });
+for (const [key, value] of Object.entries({
+ window: dom.window,
+ document: dom.window.document,
+ HTMLElement: dom.window.HTMLElement,
+ Node: dom.window.Node,
+ customElements: dom.window.customElements,
+}))
+ Object.defineProperty(globalThis, key, { configurable: true, writable: true, value });
+
+const { html, render } = await import("lit");
+const { Archive, Link, X } = await import("lucide");
+const { icon } = await import("../src/ui.ts");
+const style = document.createElement("style");
+style.textContent = readFileSync(new URL("../src/shell.css", import.meta.url), "utf8");
+document.head.append(style);
+
+for (const [label, glyph] of [
+ ["Archive session", Archive],
+ ["Share session", Link],
+ ["Close pane", X],
+] as const) {
+ test(`${label} keeps pointer targeting on the button across icon redraws`, () => {
+ const host = document.createElement("div");
+ host.className = "dv-tab dv-active-tab";
+ document.body.append(host);
+ const view = () =>
+ html`<span class="split-tab-actions"
+ ><button class="icon-btn subtle split-tab-close" type="button" aria-label=${label}>
+ ${icon(glyph, 13)}
+ </button></span
+ >`;
+ render(view(), host);
+ const button = host.querySelector("button")!;
+ const before = button.querySelector("svg")!;
+ assert.equal(dom.window.getComputedStyle(before).pointerEvents, "none");
+ render(view(), host);
+ const after = button.querySelector("svg")!;
+ assert.equal(host.querySelector("button"), button);
+ assert.notEqual(after, before);
+ assert.equal(before.isConnected, false);
+ assert.equal(dom.window.getComputedStyle(after).pointerEvents, "none");
+ for (const child of after.children) assert.equal(dom.window.getComputedStyle(child).pointerEvents, "none");
+ assert.notEqual(dom.window.getComputedStyle(button).pointerEvents, "none");
+ host.remove();
+ });
+}