@dloizides/ui-nav 1.13.0 → 1.13.1
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/CHANGELOG.md +20 -0
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.13.1
|
|
4
|
+
|
|
5
|
+
- **Fix (mobile drawer: a sub-item / leaf tap dismissed the drawer WITHOUT navigating).**
|
|
6
|
+
On a phone-width viewport, tapping a leaf inside the open `MobileDrawer` closed the drawer
|
|
7
|
+
but the route never changed — verified live on finreg via Playwright (real Chromium, real
|
|
8
|
+
pointer events); every jsdom unit test stayed green because it wired `onClose` to an inert
|
|
9
|
+
`jest.fn()` that never unmounts anything.
|
|
10
|
+
- **Root cause.** `MobileDrawer` closes on a nav press via a NATIVE
|
|
11
|
+
`panel.addEventListener('click', …)`. react-native-web fires a leaf's `onPress` from its
|
|
12
|
+
`onClick`, dispatched through REACT's synthetic event system whose root listener sits on the
|
|
13
|
+
app-root container — an ANCESTOR of the panel. So on a real click the native panel listener
|
|
14
|
+
runs FIRST (during the DOM bubble), and closing synchronously there ran `setDrawerOpen(false)`,
|
|
15
|
+
unmounting the panel and tearing the leaf out of the tree BEFORE React could dispatch its
|
|
16
|
+
`onPress`. The navigation call never ran.
|
|
17
|
+
- **Fix.** The drawer's close is now DEFERRED to the next macrotask (`setTimeout(…, 0)`), so
|
|
18
|
+
React finishes dispatching the tapped leaf's `onPress` (the navigation) for the current click;
|
|
19
|
+
the panel then unmounts on the following tick, after the route has already changed. Scrim tap
|
|
20
|
+
and group-header toggle are unchanged.
|
|
21
|
+
- **No API change.** All 7 portals get the fix on their next bump.
|
|
22
|
+
|
|
3
23
|
## 1.11.0
|
|
4
24
|
|
|
5
25
|
- **Feature (an expandable nav group now auto-opens when the current route is inside it).**
|
package/dist/index.js
CHANGED
|
@@ -1054,6 +1054,10 @@ var SCRIM_Z_INDEX = 1;
|
|
|
1054
1054
|
var PANEL_Z_INDEX = 2;
|
|
1055
1055
|
var NAV_ACTIVATABLE_SELECTOR = 'a, [role="button"], [role="link"]';
|
|
1056
1056
|
var NAV_TOGGLE_SELECTOR = "[aria-expanded]";
|
|
1057
|
+
function deferClose(close) {
|
|
1058
|
+
if (typeof setTimeout === "function") setTimeout(close, 0);
|
|
1059
|
+
else close();
|
|
1060
|
+
}
|
|
1057
1061
|
var DEFAULT_DRAWER_LABELS = {
|
|
1058
1062
|
openLabel: "Menu",
|
|
1059
1063
|
openHint: "Open the navigation menu",
|
|
@@ -1119,7 +1123,7 @@ var MobileDrawer = ({
|
|
|
1119
1123
|
if (target === null) return;
|
|
1120
1124
|
const activatable = target.closest(NAV_ACTIVATABLE_SELECTOR);
|
|
1121
1125
|
const isToggle = activatable !== null && activatable.closest(NAV_TOGGLE_SELECTOR) !== null;
|
|
1122
|
-
if (activatable !== null && !isToggle) onClose
|
|
1126
|
+
if (activatable !== null && !isToggle) deferClose(onClose);
|
|
1123
1127
|
};
|
|
1124
1128
|
node.addEventListener("click", handleClick);
|
|
1125
1129
|
return () => node.removeEventListener("click", handleClick);
|