@volo/ngx-lepton-x.core 4.3.5 → 4.3.6

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.
@@ -1450,9 +1450,8 @@ class NavbarRoutesComponent {
1450
1450
  if (!items?.length || !url) {
1451
1451
  return items;
1452
1452
  }
1453
- const updated = [...items];
1454
1453
  this.fixNavbarItems(url, items);
1455
- return updated;
1454
+ return items;
1456
1455
  });
1457
1456
  this.routerItem = input();
1458
1457
  this.routeClick = new EventEmitter();
@@ -1513,14 +1512,37 @@ class NavbarRoutesComponent {
1513
1512
  fixNavbarItems(currentUrl, items) {
1514
1513
  items.forEach((item) => {
1515
1514
  const { link, children } = item;
1515
+ const itemUrl = link?.split('?')[0];
1516
1516
  if (children?.length) {
1517
1517
  this.fixNavbarItems(currentUrl, children);
1518
- const hasActiveChild = children.some((child) => child.selected || child.expanded || child.link === currentUrl);
1519
- item.expanded ||= hasActiveChild || link === currentUrl;
1518
+ const hasActiveDescendant = this.hasActiveDescendant(children, currentUrl);
1519
+ const isInActiveChain = hasActiveDescendant || itemUrl === currentUrl;
1520
+ if (isInActiveChain) {
1521
+ item.expanded = true;
1522
+ }
1523
+ else {
1524
+ const hasExpandedChildren = children.some(child => child.expanded);
1525
+ if (!hasExpandedChildren) {
1526
+ item.expanded = false;
1527
+ }
1528
+ }
1529
+ item.selected = false;
1520
1530
  }
1521
1531
  else {
1522
- item.selected = link === currentUrl;
1532
+ item.selected = itemUrl === currentUrl;
1533
+ }
1534
+ });
1535
+ }
1536
+ hasActiveDescendant(items, currentUrl) {
1537
+ return items.some((item) => {
1538
+ const itemUrl = item.link?.split('?')[0];
1539
+ if (item.selected || itemUrl === currentUrl) {
1540
+ return true;
1541
+ }
1542
+ if (item.children?.length) {
1543
+ return this.hasActiveDescendant(item.children, currentUrl);
1523
1544
  }
1545
+ return false;
1524
1546
  });
1525
1547
  }
1526
1548
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.0.7", ngImport: i0, type: NavbarRoutesComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }