Skip to content

Conversation

renczesstefan
Copy link
Member

@renczesstefan renczesstefan commented Oct 3, 2025

Description

Added additional check, whether the item on the same path is selected through menu item click.

Fixes NAE-2226

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

This was tested manually, and with unit tests.

Test Configuration

Name Tested on
OS macOS Tahoe 26.0.1
Runtime Node 20.17.0
Dependency Manager NPM 10.8.2
Framework version Angular 13.3.1
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 @renczesnetgrif
  • 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
    • Navigation drawer now clears selection when tapping items that have no associated view, preventing stale highlights.
    • Skips view resolution when the clicked item is already represented among available options, avoiding unintended view switches.
    • Improves stability and predictability of item selection and view opening in the double-drawer navigation.

- added additional check to openAvailableView method in double-drawer-navigation.service.ts
Copy link

coderabbitai bot commented Oct 3, 2025

Walkthrough

Adjusts double-drawer navigation click handling to set or clear the current navigation item based on presence of item.resource, and adds an early-return in view resolution when a matching view already exists among right/more items.

Changes

Cohort / File(s) Summary
Navigation double-drawer service
projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/service/double-drawer-navigation.service.ts
- onItemClick: sets _currentNavigationItem to null when item.resource is undefined; otherwise sets it to the clicked item.
- openAvailableView: adds guard to check combined right+more items for a match to _currentNavigationItem and returns early if found, skipping further view resolution; docstring updated to reflect changed check order.

Sequence Diagram(s)

sequenceDiagram
  participant UI as UI
  participant Svc as DoubleDrawerNavigationService
  participant Views as AvailableViews

  rect rgb(245,248,255)
  note over UI,Svc: onItemClick
  UI->>Svc: onItemClick(item)
  alt item.resource is defined
    Svc->>Svc: _currentNavigationItem = item
  else item.resource is undefined
    Svc->>Svc: _currentNavigationItem = null
  end
  end

  rect rgb(245,255,245)
  note over Svc,Views: openAvailableView
  Svc->>Svc: Check combined right+more items for match to _currentNavigationItem
  alt match exists
    Svc-->>UI: Return early (no further resolution)
  else no match
    Svc->>Views: Resolve and open view
    Views-->>Svc: View instance
    Svc-->>UI: Opened/updated view
  end
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • [NAE-2202] Post test fixes #298 — Modifies the same double-drawer navigation service and related view-resolution logic; likely related to openAvailableView changes.

Pre-merge checks

✅ Passed checks (3 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly references the core issue addressed by the changeset, namely the inability to switch between menu items, and it is concise and specific. It directly relates to the main change without extraneous details.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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.

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

Caution

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

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

295-319: Add null-safety check to prevent NPE.

The early-return logic at lines 298-302 correctly addresses NAE-2226 by preventing redundant view resolution when clicking an item already in the current menu. However, _currentNavigationItem can be null (set at line 256), which will cause a null-pointer exception when accessing .id.

Apply this diff to add a null-safety check:

 public openAvailableView() {
     let allItems: Array<NavigationItem> = this.rightItems.concat(this.moreItems);
 
-    let alreadyClickedItem: NavigationItem = allItems.find(item => item.id === this._currentNavigationItem.id);
-    if (!!alreadyClickedItem) {
+    if (this._currentNavigationItem) {
+        let alreadyClickedItem: NavigationItem = allItems.find(item => item.id === this._currentNavigationItem.id);
+        if (!!alreadyClickedItem) {
-        // when the folder has not changed and a menu item is clicked.
-        return;
-    }
+            // when the folder has not changed and a menu item is clicked.
+            return;
+        }
+    }
 
     let autoOpenItems: Array<NavigationItem> = allItems.filter(item => DoubleDrawerUtils.hasItemAutoOpenView(item));

254-286: Reset _currentNavigationItem on all navigation flows

Currently _currentNavigationItem is only initialized in the constructor and set in onItemClick; it isn’t cleared when the user navigates via home/back buttons, direct URL changes, or other path updates. Add logic in your navigation handlers (e.g. homeClick, pathService URL subscription, back navigation) to reset _currentNavigationItem to avoid stale references triggering the early‐return in openAvailableView.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e526b0e and 1c1e07a.

📒 Files selected for processing (1)
  • 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). (10)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: Matrix Test (22)
  • GitHub Check: Test with SonarCloud
  • GitHub Check: Matrix Test (24)
  • GitHub Check: Matrix Test (20)
  • GitHub Check: task-list-completed

Refined documentation in the openAvailableView method to improve clarity and readability. Adjusted the descriptions of the rule to make the order and logic more explicit.
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 1c1e07a and a2084e0.

📒 Files selected for processing (1)
  • 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). (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

Copy link

sonarqubecloud bot commented Oct 3, 2025

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

@machacjozef machacjozef merged commit 0a6f7f7 into release/7.0.0-rev8 Oct 3, 2025
10 of 11 checks passed
@machacjozef machacjozef deleted the NAE-2226 branch October 3, 2025 13:51
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.

2 participants