@greatapps/greatauth-ui 0.3.16 → 0.3.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greatapps/greatauth-ui",
3
- "version": "0.3.16",
3
+ "version": "0.3.18",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
 
3
+ import { useState, useEffect } from "react";
3
4
  import { usePathname, useRouter } from "next/navigation";
4
5
  import Link from "next/link";
5
6
  import { ChevronsUpDown, ChevronRight, LogOut } from "lucide-react";
@@ -76,9 +77,16 @@ function CollapsibleMenuItem({ item, pathname }: { item: MenuItem; pathname: str
76
77
  const isChildActive = item.children?.some((child) =>
77
78
  child.isActive !== undefined ? child.isActive : pathname.startsWith(child.href)
78
79
  ) ?? false;
80
+ const isActive = isParentActive || isChildActive;
81
+
82
+ const [open, setOpen] = useState(isActive);
83
+
84
+ useEffect(() => {
85
+ setOpen(isActive);
86
+ }, [isActive]);
79
87
 
80
88
  return (
81
- <Collapsible defaultOpen={isParentActive || isChildActive} className="group/collapsible">
89
+ <Collapsible open={open} onOpenChange={setOpen} className="group/collapsible">
82
90
  <SidebarMenuItem>
83
91
  <SidebarMenuButton asChild isActive={isParentActive} tooltip={item.label}>
84
92
  <Link href={item.href} onClick={item.onClick}>