MCPcopy Create free account
hub / github.com/szhsin/react-menu / createSubmenuCtx

Function createSubmenuCtx

src/utils/submenuCtx.js:1–27  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1const createSubmenuCtx = () => {
2 let timer,
3 count = 0;
4 return {
5 toggle: (isOpen) => {
6 isOpen ? count++ : count--;
7 count = Math.max(count, 0);
8 },
9 on: (closeDelay, pending, settled) => {
10 if (count) {
11 if (!timer)
12 timer = setTimeout(() => {
13 timer = 0;
14 pending();
15 }, closeDelay);
16 } else {
17 settled?.();
18 }
19 },
20 off: () => {
21 if (timer) {
22 clearTimeout(timer);
23 timer = 0;
24 }
25 }
26 };
27};
28
29export { createSubmenuCtx };

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…