Skip to content

Commit 0a6f7f7

Browse files
authored
Merge pull request #302 from netgrif/NAE-2226d
[NAE-2226] Cannot switch between menu items
2 parents 9237790 + d78511d commit 0a6f7f7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,7 @@ export class DoubleDrawerNavigationService implements OnDestroy {
253253
* */
254254
public onItemClick(item: NavigationItem): void {
255255
if (item.resource === undefined) {
256+
this._currentNavigationItem = null;
256257
// custom view represented only in nae.json
257258
if (item.processUri === this.currentPath) {
258259
this._pathService.activePath = this.currentPath;
@@ -261,6 +262,7 @@ export class DoubleDrawerNavigationService implements OnDestroy {
261262
}
262263
this.itemClicked.emit({path: this._pathService.activePath, isHome: false});
263264
} else {
265+
this._currentNavigationItem = item;
264266
const path = item.resource.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value
265267

266268
if (DoubleDrawerUtils.hasItemChildren(item) && !this.leftLoading$.isActive && !this.rightLoading$.isActive) {
@@ -285,13 +287,22 @@ export class DoubleDrawerNavigationService implements OnDestroy {
285287

286288

287289
/**
288-
* Opens a view of the current right items in the menu by defined rule. The rule is: On first check for default
289-
* view in children. On second check if the clicked item has a view. On third, pick any other children's view, else
290+
* Opens a view of the current right items in the menu by defined rule. The rule is: First, it checks whether a navigation
291+
* item was clicked. Second, check for default view in children.
292+
* Third check if the clicked item has a view. Fourth, pick any other children's view, else
290293
* show nothing.
291294
* */
292295
public openAvailableView() {
293296
let allItems: Array<NavigationItem> = this.rightItems.concat(this.moreItems);
294297

298+
if (this._currentNavigationItem) {
299+
let alreadyClickedItem: NavigationItem = allItems.find(item => item.id === this._currentNavigationItem.id);
300+
if (!!alreadyClickedItem) {
301+
// when the folder has not changed and a menu item is clicked.
302+
return;
303+
}
304+
}
305+
295306
let autoOpenItems: Array<NavigationItem> = allItems.filter(item => DoubleDrawerUtils.hasItemAutoOpenView(item));
296307
if (autoOpenItems.length > 0) {
297308
this._redirectService.redirect(autoOpenItems[0].routing.path);

0 commit comments

Comments
 (0)