MCPcopy Create free account
hub / github.com/pingdotgg/t3code / isNodeWithinMenuStack

Function isNodeWithinMenuStack

apps/web/src/contextMenuFallback.ts:86–102  ·  view source on GitHub ↗
(target: EventTarget | null, menuStack: readonly HTMLDivElement[])

Source from the content-addressed store, hash-verified

84}
85
86function isNodeWithinMenuStack(target: EventTarget | null, menuStack: readonly HTMLDivElement[]) {
87 if (typeof Node !== "undefined" && target instanceof Node) {
88 return menuStack.some((menu) => menu.contains(target));
89 }
90 if (!target || typeof target !== "object") {
91 return false;
92 }
93
94 let current: unknown = target;
95 while (current && typeof current === "object") {
96 if (menuStack.includes(current as HTMLDivElement)) {
97 return true;
98 }
99 current = (current as { parent?: unknown }).parent;
100 }
101 return false;
102}
103
104/**
105 * Imperative DOM-based context menu for non-Electron environments.

Callers 2

onPointerDownFunction · 0.85
onContextMenuFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected