Skip to content

Angular 9,10 NSRouterLinkActive does not set CSS class #2224

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
denlysenko opened this issue Aug 18, 2020 · 5 comments · Fixed by #2225 or #2227
Closed

Angular 9,10 NSRouterLinkActive does not set CSS class #2224

denlysenko opened this issue Aug 18, 2020 · 5 comments · Fixed by #2225 or #2227

Comments

@denlysenko
Copy link
Contributor

After upgrading Angular from 8 to 10, nsRouterLinkActive directive stopped adding CSS class on element. Seems like the reason is in this this.renderer.setStyle(should be this.renderer.addClass) call here

this.classes.forEach((c) => this.renderer.setStyle(this.element.nativeElement, c, isActiveLinks));

@NathanWalker
Copy link
Contributor

Thanks @denlysenko we’ll get this updated and publish a patch this afternoon.

@NathanWalker
Copy link
Contributor

@denlysenko published in 10.0.1 - let us know if you have further issue; thanks again for report.

@denlysenko
Copy link
Contributor Author

@NathanWalker After your fix CSS class is being added, but it's added to the link, which is not active.
I guess you should swap removeClass and addClass in this if/else

if (isActiveLinks) {
this.renderer.removeClass(this.element.nativeElement, c);
} else {
this.renderer.addClass(this.element.nativeElement, c);
}

@NathanWalker
Copy link
Contributor

Ah @denlysenko thanks, do you wanna try to submit a PR?

@denlysenko
Copy link
Contributor Author

ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants