@mlola-ui/behavior 1.1.13 → 1.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +11 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mlola-ui/behavior",
3
- "version": "1.1.13",
3
+ "version": "1.1.15",
4
4
  "description": "Framework-free behavior for Mlola UI markup: standard DOM, no runtime peers",
5
5
  "type": "module",
6
6
  "main": "./src/index.js",
package/src/index.js CHANGED
@@ -582,9 +582,17 @@ const behaviors = {
582
582
  on(root, "pointerleave", hide),
583
583
  on(root, "focusin", show),
584
584
  on(root, "focusout", hide),
585
- on(document, "keydown", (event) => {
586
- if (event.key === "Escape") hide();
587
- }),
585
+ // Heard before a dialog around it (capture), and marked as used while the tip shows, so one Escape closes one layer.
586
+ on(
587
+ document,
588
+ "keydown",
589
+ (event) => {
590
+ if (event.key !== "Escape" || tip.hidden || event.defaultPrevented) return;
591
+ event.preventDefault();
592
+ hide();
593
+ },
594
+ true,
595
+ ),
588
596
  ];
589
597
  },
590
598