@dloizides/ui-nav 1.10.2 → 1.11.0
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 +23 -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,28 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.11.0
|
|
4
|
+
|
|
5
|
+
- **Feature (an expandable nav group now auto-opens when the current route is inside it).**
|
|
6
|
+
`NavExpandableItem` used to mount every group collapsed (`useState(false)`), so on a fresh
|
|
7
|
+
page load the group containing the active route was closed and its active leaf was hidden.
|
|
8
|
+
A persistent-rail console that groups its nav by module (e.g. finreg-web's Payments / CRM /
|
|
9
|
+
Accounting rail) needs the active module's group open on load, the others collapsed — with
|
|
10
|
+
no way for the caller to express that, since expansion state was internal and uncontrolled.
|
|
11
|
+
- The group now initializes its expansion from whether the current route is inside it:
|
|
12
|
+
`useState(() => hasActiveDescendant(item, pathname))`, where `hasActiveDescendant` is true
|
|
13
|
+
when the item's own route is active (`isRouteActive`) or any descendant's is (recursive, so
|
|
14
|
+
it holds at any nesting depth). The group of the active route mounts EXPANDED (active leaf
|
|
15
|
+
visible + highlighted); a group with no active descendant mounts COLLAPSED — exactly the
|
|
16
|
+
prior behaviour.
|
|
17
|
+
- **No API change.** `NavItem` is unchanged — the behaviour is derived from the `pathname`
|
|
18
|
+
the component already receives. Consumers with no expandable groups, or whose groups hold no
|
|
19
|
+
active route, are byte-for-byte unaffected; all 7 portals gain the auto-open on their next
|
|
20
|
+
bump for free.
|
|
21
|
+
- Guarded by `src/navExpandableItem.test.tsx` (RED-first): the two "mounts EXPANDED" assertions
|
|
22
|
+
FAIL against the pre-change `useState(false)` (the active group's child is absent from the DOM)
|
|
23
|
+
and pass after; the "mounts COLLAPSED" + "header always renders" assertions lock the
|
|
24
|
+
backward-compatible half.
|
|
25
|
+
|
|
3
26
|
## 1.10.2
|
|
4
27
|
|
|
5
28
|
- **Fix (the mobile nav DRAWER was not clickable — a tap on a nav item did not navigate, it
|
package/dist/index.js
CHANGED
|
@@ -289,6 +289,10 @@ function hoverTransitionStyle(reducedMotion) {
|
|
|
289
289
|
function ariaCurrentProps(isActive) {
|
|
290
290
|
return isActive ? { "aria-current": "page" } : {};
|
|
291
291
|
}
|
|
292
|
+
function hasActiveDescendant(item, pathname) {
|
|
293
|
+
if (isRouteActive(pathname, item.route)) return true;
|
|
294
|
+
return (item.children ?? []).some((child) => hasActiveDescendant(child, pathname));
|
|
295
|
+
}
|
|
292
296
|
var NavExpandableItem = ({
|
|
293
297
|
item,
|
|
294
298
|
pathname,
|
|
@@ -299,7 +303,7 @@ var NavExpandableItem = ({
|
|
|
299
303
|
renderChevron,
|
|
300
304
|
depth = 0
|
|
301
305
|
}) => {
|
|
302
|
-
const [expanded, setExpanded] = React2.useState(
|
|
306
|
+
const [expanded, setExpanded] = React2.useState(() => hasActiveDescendant(item, pathname));
|
|
303
307
|
const [focused, setFocused] = React2.useState(false);
|
|
304
308
|
const { theme } = uiFeedback.useUi();
|
|
305
309
|
const colors = theme.colors;
|