@astralui/core 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -610,12 +610,21 @@ function AstralMenu({ trigger, items, align = "end", width = 220 }) {
|
|
|
610
610
|
if (menuRef.current?.contains(e.target)) return;
|
|
611
611
|
setOpen(false);
|
|
612
612
|
};
|
|
613
|
+
const onKey = (e) => {
|
|
614
|
+
if (e.key !== "Escape") return;
|
|
615
|
+
e.preventDefault();
|
|
616
|
+
e.stopPropagation();
|
|
617
|
+
setOpen(false);
|
|
618
|
+
anchorRef.current?.querySelector(FOCUSABLE)?.focus();
|
|
619
|
+
};
|
|
613
620
|
window.addEventListener("scroll", onScroll, true);
|
|
614
621
|
window.addEventListener("resize", onResize);
|
|
622
|
+
window.addEventListener("keydown", onKey, true);
|
|
615
623
|
document.addEventListener("mousedown", onDoc, true);
|
|
616
624
|
return () => {
|
|
617
625
|
window.removeEventListener("scroll", onScroll, true);
|
|
618
626
|
window.removeEventListener("resize", onResize);
|
|
627
|
+
window.removeEventListener("keydown", onKey, true);
|
|
619
628
|
document.removeEventListener("mousedown", onDoc, true);
|
|
620
629
|
};
|
|
621
630
|
}, [open, reposition]);
|