Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix: prevent initial right-click from selecting a context menu item (#3877)

Fazal Kadivare057e2e98583
diff --git a/apps/web/src/contextMenuFallback.test.ts b/apps/web/src/contextMenuFallback.test.ts
index 56b4596b9..29596e72a 100644
--- a/apps/web/src/contextMenuFallback.test.ts
+++ b/apps/web/src/contextMenuFallback.test.ts
@@ -196,6 +196,23 @@ describe("showContextMenuFallback", () => {
await expect(selectionPromise).resolves.toBe("rename");
});
+ it("ignores a click from the gesture that opened the menu", async () => {
+ let enablePointerSelection: ((time: number) => void) | undefined;
+ vi.stubGlobal("requestAnimationFrame", (callback: (time: number) => void) => {
+ enablePointerSelection = callback;
+ return 0;
+ });
+
+ const selectionPromise = showContextMenuFallback([{ id: "rename", label: "Rename" }]);
+ const renameButton = findButton("Rename");
+
+ renameButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+ enablePointerSelection?.(0);
+ renameButton?.dispatchEvent(new MouseEvent("click", { bubbles: true }));
+
+ await expect(selectionPromise).resolves.toBe("rename");
+ });
+
it("opens nested submenus and resolves the clicked leaf id", async () => {
const selectionPromise = showContextMenuFallback([
{
diff --git a/apps/web/src/contextMenuFallback.ts b/apps/web/src/contextMenuFallback.ts
index a301e0c92..9b3bb94db 100644
--- a/apps/web/src/contextMenuFallback.ts
+++ b/apps/web/src/contextMenuFallback.ts
@@ -272,7 +272,9 @@ export function showContextMenuFallback<T extends string>(
button.addEventListener("mouseenter", () => {
closeMenusFromLevel(level + 1);
});
- button.addEventListener("click", () => cleanup(item.id));
+ button.addEventListener("click", () => {
+ if (canDismissFromPointer) cleanup(item.id);
+ });
}
}