Skip to content

Conversation

Kovy95
Copy link
Contributor

@Kovy95 Kovy95 commented Oct 13, 2025

Description

  • fix the problem with bad resolving of double drawer items when the dashboard item is view and not the folder menu item

Fixes NAE-2233

Dependencies

none

Third party dependencies

  • No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

manually

Test Configuration

Name Tested on
OS linux mint 21
Runtime node 20.18.0
Dependency Manager npm 10.8.2
Framework version angular 17
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • Bug Fixes
    • Dashboard navigation: selecting leaf items now highlights the correct parent section while groups continue to select directly.
    • Double-drawer navigation: fixed inconsistent current selection to prevent stale or missing item states.
    • Path resolution: improved handling of root and nested paths to reduce misrouting and incorrect menu highlighting.

- fix the problem with bad resolving of double drawer items when the dashboard item is view and not the folder menu item
@Kovy95 Kovy95 self-assigned this Oct 13, 2025
@coderabbitai
Copy link

coderabbitai bot commented Oct 13, 2025

Walkthrough

Adjusts dashboard navigation to set activePath to a parent path for items without children, exposes a public setter to assign the current navigation item on DoubleDrawerNavigationService, replaces internal null with undefined, and renames/makes the parent-path helper public as extractParentPath.

Changes

Cohort / File(s) Summary
Dashboard navigation flow
projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts
Changed navigate logic: if the item has children and a nodePath exists, clear currentNavigationItem and set activePath = nodePath; otherwise resolve the navigation item by nodePath, set currentNavigationItem if found, and set activePath to the parent via extractParentPath(nodePath).
Double-drawer navigation service
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts
Made _currentNavigationItem typed as `NavigationItem

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant ADC as AbstractDashboardComponent
  participant DDNS as DoubleDrawerNavigationService

  User->>ADC: select navigation item
  ADC->>ADC: check hasChildren and nodePath
  alt hasChildren && nodePath
    ADC->>DDNS: set currentNavigationItem = undefined
    ADC->>ADC: activePath = nodePath
  else nodePath present only
    ADC->>DDNS: resolve navigation item by nodePath
    DDNS-->>ADC: NavigationItem | undefined
    alt item found
      ADC->>DDNS: set currentNavigationItem(item)
    else no item
      Note over ADC: currentNavigationItem unchanged
    end
    ADC->>ADC: activePath = extractParentPath(nodePath)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title succinctly conveys that this pull request addresses a dashboard menu bug, aligning well with the primary changeset focus on fixing navigation issues for dashboard items.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai bot added the bugfix label Oct 13, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts (3)

259-266: Use the setter (after widening) instead of touching the backing field

Replace direct field mutation with the public setter for consistency and to keep semantics centralized.

-            this._currentNavigationItem = undefined;
+            this.currentNavigationItem = undefined;

270-283: Guard against undefined path before calling .includes

path can be undefined (optional chaining in Line 270). Calling path.includes(...) will throw.

-            } else if (!path.includes(this.currentPath)) {
+            } else if (path && !path.includes(this.currentPath)) {
                 this._pathService.activePath = this.extractParent(this.currentPath);

321-324: Wrong redirect source when falling back to “items with view”

You compute itemsWithView but redirect using autoOpenItems[0]. Should redirect to itemsWithView[0].

-            this._redirectService.redirect(autoOpenItems[0].routing.path);
+            this._redirectService.redirect(itemsWithView[0].routing.path);
📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b1bddbd and dbd1345.

📒 Files selected for processing (2)
  • projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts (3 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts (1)
projects/netgrif-components-core/src/lib/navigation/model/navigation-configs.ts (1)
  • NavigationItem (12-16)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Matrix Test (24)
  • GitHub Check: Matrix Test (20)
  • GitHub Check: Test with SonarCloud
  • GitHub Check: Matrix Test (22)

Comment on lines 268 to 277
if (menuItemCase.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_HAS_CHILDREN)?.value && nodePath) {
this._doubleDrawerNavigationService.currentNavigationItem = undefined;
this._pathService.activePath = nodePath;
} else if (nodePath) {
const menuItem = this._doubleDrawerNavigationService.resolveItemCaseToNavigationItem(menuItemCase);
if (menuItem) {
this._doubleDrawerNavigationService.currentNavigationItem = menuItem;
}
this._pathService.activePath = this.extractParent(nodePath);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

Compile-time mismatch: assigning undefined to setter typed as NavigationItem

This line relies on DoubleDrawerNavigationService.currentNavigationItem accepting undefined. Update the service to type both the backing field and setter as NavigationItem | undefined (see service comment), or introduce a clearCurrentNavigationItem() method.

No code change needed here after widening.

After adjusting the service types, re-run:


🏁 Script executed:

#!/bin/bash
rg -n -C2 '\bcurrentNavigationItem\s*=' projects/netgrif-components-core

Length of output: 1747


🏁 Script executed:

#!/bin/bash
rg -nP '(get|set)\s+currentNavigationItem' -C3 projects/netgrif-components-core/src/lib/navigation

Length of output: 1003


Widen currentNavigationItem setter signature to accept undefined
The currentNavigationItem setter in DoubleDrawerNavigationService is currently typed as item: NavigationItem, so assigning undefined on line 269/274 causes a compile error. Change its signature to set currentNavigationItem(item: NavigationItem | undefined) or provide a clearCurrentNavigationItem() method.

🤖 Prompt for AI Agents
In
projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts
around lines 268 to 277, the code assigns undefined to
_doubleDrawerNavigationService.currentNavigationItem which conflicts with the
setter typed as NavigationItem; update the DoubleDrawerNavigationService API so
the setter accepts undefined by changing its signature to set
currentNavigationItem(item: NavigationItem | undefined) (and keep existing
behavior), or alternatively add a clearCurrentNavigationItem(): void method and
replace assignments of undefined with calls to that method; after updating the
service, adjust imports/types if needed and rebuild to ensure the compile error
is resolved.

- resolve coderabbit suggestions
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between dbd1345 and 61c020c.

📒 Files selected for processing (2)
  • projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts (9 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts (1)
projects/netgrif-components-core/src/lib/navigation/model/navigation-configs.ts (1)
  • NavigationItem (12-16)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: Matrix Test (22)
  • GitHub Check: Matrix Test (20)
  • GitHub Check: Matrix Test (24)
  • GitHub Check: Test with SonarCloud
  • GitHub Check: task-list-completed
🔇 Additional comments (7)
projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts (1)

268-277: LGTM! Navigation logic correctly distinguishes folders from leaf items.

The refactored logic appropriately handles two navigation scenarios:

  • Folders with children: Navigate to the folder's path and clear the current item (lines 268-270)
  • Leaf items without children: Resolve and set the current item, then navigate to the parent path (lines 271-276)

The implementation includes proper error handling by checking if menuItem exists before assignment (line 273), and leverages the newly exposed extractParentPath method from the navigation service.

projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts (6)

79-79: LGTM! Field type widened to accept undefined.

This change resolves the type mismatch issue flagged in previous reviews and aligns with the new setter signature.


106-106: LGTM! Initialization aligned with undefined semantics.

Replacing null with undefined is consistent with the updated type signature and TypeScript best practices.


148-150: LGTM! Public setter exposed as requested in past reviews.

The setter correctly accepts NavigationItem | undefined and provides external components with the ability to manage navigation state.


249-249: LGTM! Method calls updated to use renamed public method.

All invocations correctly reference extractParentPath, maintaining consistency with the method visibility change.

Also applies to: 265-265, 282-282


383-383: LGTM! Method calls updated consistently.

All references to the path extraction utility correctly use the renamed public method.

Also applies to: 517-519


597-605: LGTM! Method visibility and naming improved.

Making extractParentPath public and giving it a more descriptive name addresses the code duplication concern from past reviews. The implementation correctly handles root and top-level paths.

Retoocs
Retoocs previously approved these changes Oct 14, 2025
machacjozef
machacjozef previously approved these changes Oct 14, 2025
@machacjozef machacjozef changed the base branch from release/7.0.0-rev9 to release/7.0.0-rev8 October 20, 2025 12:18
@machacjozef machacjozef dismissed stale reviews from Retoocs and themself October 20, 2025 12:18

The base branch was changed.

@Kovy95 Kovy95 mentioned this pull request Oct 20, 2025
18 tasks
@machacjozef machacjozef merged commit 73e3183 into release/7.0.0-rev8 Oct 20, 2025
7 checks passed
@machacjozef machacjozef deleted the NAE-2233 branch October 20, 2025 14:07
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.3% Coverage on New Code (required ≥ 50%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants