@yatoday/astro-ui 0.18.0 → 0.18.2
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.
|
@@ -344,6 +344,12 @@ const panelItems = links.map((link, index) => ({ link, index })).filter(({ link
|
|
|
344
344
|
opacity 0.18s ease,
|
|
345
345
|
transform 0.18s ease,
|
|
346
346
|
visibility 0s linear 0.18s;
|
|
347
|
+
/* Wrapper is full-width; only the visible box should catch clicks so a click
|
|
348
|
+
to the side of the panel falls through to the page (and closes the menu). */
|
|
349
|
+
pointer-events: none;
|
|
350
|
+
}
|
|
351
|
+
.flyout-bg {
|
|
352
|
+
pointer-events: auto;
|
|
347
353
|
}
|
|
348
354
|
.flyout.is-open {
|
|
349
355
|
opacity: 1;
|
|
@@ -533,9 +539,11 @@ const panelItems = links.map((link, index) => ({ link, index })).filter(({ link
|
|
|
533
539
|
const key = trigger.dataset.flyoutKey!;
|
|
534
540
|
trigger.addEventListener('mouseenter', () => openTo(key));
|
|
535
541
|
trigger.addEventListener('focus', () => openTo(key));
|
|
542
|
+
// Clicking a trigger only ever opens (never toggles closed) so a click that
|
|
543
|
+
// races the open animation can't dismiss the menu the user just summoned.
|
|
536
544
|
trigger.addEventListener('click', (e) => {
|
|
537
545
|
e.preventDefault();
|
|
538
|
-
|
|
546
|
+
openTo(key);
|
|
539
547
|
});
|
|
540
548
|
});
|
|
541
549
|
|
|
@@ -553,8 +561,11 @@ const panelItems = links.map((link, index) => ({ link, index })).filter(({ link
|
|
|
553
561
|
document.addEventListener('keydown', (e) => {
|
|
554
562
|
if (e.key === 'Escape') close();
|
|
555
563
|
});
|
|
564
|
+
// Close on any click outside the *visible* box (bgEl) or the nav. The flyout
|
|
565
|
+
// wrapper spans the full width, so clicking to the side of the panel must not
|
|
566
|
+
// count as "inside" — otherwise the menu would stay stuck open.
|
|
556
567
|
document.addEventListener('click', (e) => {
|
|
557
|
-
if (open && !
|
|
568
|
+
if (open && !bgEl.contains(e.target as Node) && !nav?.contains(e.target as Node)) close();
|
|
558
569
|
});
|
|
559
570
|
window.addEventListener('resize', () => {
|
|
560
571
|
if (open && currentKey) {
|