question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pages menu linking to site root fails to activate

See original GitHub issue

Issue type

I’m submitting a … (check one with “x”)

  • bug report
  • feature request

Issue description

Current behavior:

When you add a menu item to the site root (“/”) it fails to activate when you click on it. The menu item of the previously visited page stays active instead.

Expected behavior:

The menu activates when clicking on the menu item or navigating to the site root (“/”).

Steps to reproduce:

Setup the pages component to the site root and create a menu item linking to the site root.

Related code:

const routes: Routes = [
  {
    path: 'auth',
    component: NbAuthComponent,
    children: [
       ...
    ],
  },
  { path: '', loadChildren: 'app/pages/pages.module#PagesModule' },
];

const routes: Routes = [{
  path: '',
  component: PagesComponent,
  children: [
    {
      path: '',
      component: DashboardComponent,
    },
   ...
  ],
}];

export const MENU_ITEMS: NbMenuItem[] = [
  {
    title: 'Dashboard',
    icon: 'nb-home',
    link: '/',
    home: true,
  },
  {
    title: 'Search',
    icon: 'nb-search',
    link: '/search',
  },
];

Other information:

npm, node, OS, Browser

node v11.9.0
npm 6.7.0
Chromium Version 72.0.3626.96 (Official Build) Arch Linux (64-bit)
4.20.7-arch1-1-ARCH

Angular, Nebular

Angular 7.0.3
Nebular 3.0.0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:2
  • Comments:5

github_iconTop GitHub Comments

1reaction
Malbeth81commented, Feb 15, 2019

Found a temporary fix involving ngDoCheck():

import { Component, DoCheck } from '@angular/core';

...

export class PagesComponent implements DoCheck {

  menu = MENU_ITEMS;

  constructor(private location: Location) {
  }

  ngDoCheck(): void {
    // Fix for https://github.com/akveo/nebular/issues/1242
    if (this.location.path() === '' && !this.menu[0].selected) {
      // Select home menu item when navigating to the site root
      var i: any;
      for (i in this.menu) {
        this.menu[i].selected = (i == 0);
      }
    }
  }
}
0reactions
kapikcommented, Nov 4, 2021

Any news ? 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Navigation menu will not link to my other pages - Stack Overflow
I used HTML and Sublime 2. The webpage locating the menu directory seems to be my main issue. # <!doctype html> <html ...
Read more >
How to enable the root user or change the root password on ...
To enable the root user, choose Edit > Enable Root User from the menu bar. Then enter the password that you want to...
Read more >
How to fix the "WordPress links not working" error
Method #3: Disable WordPress Plugins and Themes​​ If the “WordPress links not working” error is still there, this solution might help. Try to...
Read more >
Error 404: 4 Ways to Fix It - Hostinger
Error 404 is a response code, meaning the server could not locate the requested content. Check this article to learn 4 steps to...
Read more >
How To Fix "The Link You Followed Has Expired" Error in ...
This error usually occurs when you are trying to upload a WordPress theme or a plugin to your website from the WordPress admin...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found