@muten/shadcn 0.2.17 → 0.2.18
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/package.json
CHANGED
|
@@ -29,7 +29,8 @@ export function mount(el, inputs, on) {
|
|
|
29
29
|
// the auto mode is resolved NOW (and again when the width crosses the phone line while closed), never at the moment
|
|
30
30
|
// of opening: a dialog that only learns it is a dialog as it opens animates its centring from the corner
|
|
31
31
|
const resolve = () => { if (auto && !isOpen) mdl.dataset.mode = phone.matches ? 'drawer' : 'dialog'; };
|
|
32
|
-
|
|
32
|
+
// pushedAt: the address when this modal added its step; a page that moves the address to close it took that step's place
|
|
33
|
+
let isOpen = false, pushed = false, pushedAt = '', lastFocus = null;
|
|
33
34
|
const me = { onPop: () => { if (isOpen) { pushed = false; close(); } } };
|
|
34
35
|
queueMicrotask(() => resolve()); phone.addEventListener('change', resolve);
|
|
35
36
|
// the footer sticks under the scrolling body, not inside it
|
|
@@ -64,7 +65,7 @@ export function mount(el, inputs, on) {
|
|
|
64
65
|
document.documentElement.classList.add('cx-locked');
|
|
65
66
|
// on the phone, focusing a field would throw the keyboard over the sheet: focus the sheet itself
|
|
66
67
|
requestAnimationFrame(() => { ((mdl.dataset.mode === 'dialog' && focusables().find((x) => x.matches('input, textarea'))) || mdl).focus({ preventScroll: true }); });
|
|
67
|
-
const push = () => { if (!isOpen || pushed) return; history.pushState({ cxModal: 1 }, ''); pushed = true; };
|
|
68
|
+
const push = () => { if (!isOpen || pushed) return; history.pushState({ cxModal: 1 }, ''); pushed = true; pushedAt = location.href; };
|
|
68
69
|
if (stack.skip > 0) stack.after.push(push); else push();
|
|
69
70
|
};
|
|
70
71
|
const shut = () => {
|
|
@@ -73,7 +74,10 @@ export function mount(el, inputs, on) {
|
|
|
73
74
|
stack.list = stack.list.filter((one) => one !== me);
|
|
74
75
|
if (stack.list.length === 0) document.documentElement.classList.remove('cx-locked');
|
|
75
76
|
lastFocus?.focus?.({ preventScroll: true });
|
|
76
|
-
|
|
77
|
+
// A PAGE THAT CLOSES IT BY MOVING THE ADDRESS (a sheet kept in ?sheet=, closed with url.set): its new step already
|
|
78
|
+
// stands where the modal's was, and going back from it lands on the address that opened the sheet, which opened it
|
|
79
|
+
// again (Platform's «Avisar» never closed, 1 Nov 2026). The modal goes back only from its own step.
|
|
80
|
+
if (pushed) { pushed = false; if (location.href === pushedAt) { stack.skip += 1; history.back(); } }
|
|
77
81
|
};
|
|
78
82
|
mdl.tabIndex = -1;
|
|
79
83
|
// A link inside (a menu in a drawer): close first, then go. Closing undoes the history entry the modal pushed, and
|