@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/dist/index.mjs
CHANGED
|
@@ -283,6 +283,10 @@ function hoverTransitionStyle(reducedMotion) {
|
|
|
283
283
|
function ariaCurrentProps(isActive) {
|
|
284
284
|
return isActive ? { "aria-current": "page" } : {};
|
|
285
285
|
}
|
|
286
|
+
function hasActiveDescendant(item, pathname) {
|
|
287
|
+
if (isRouteActive(pathname, item.route)) return true;
|
|
288
|
+
return (item.children ?? []).some((child) => hasActiveDescendant(child, pathname));
|
|
289
|
+
}
|
|
286
290
|
var NavExpandableItem = ({
|
|
287
291
|
item,
|
|
288
292
|
pathname,
|
|
@@ -293,7 +297,7 @@ var NavExpandableItem = ({
|
|
|
293
297
|
renderChevron,
|
|
294
298
|
depth = 0
|
|
295
299
|
}) => {
|
|
296
|
-
const [expanded, setExpanded] = useState(
|
|
300
|
+
const [expanded, setExpanded] = useState(() => hasActiveDescendant(item, pathname));
|
|
297
301
|
const [focused, setFocused] = useState(false);
|
|
298
302
|
const { theme } = useUi();
|
|
299
303
|
const colors = theme.colors;
|