Skip to content

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

Description

@denlysenko

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));

Activity

  1. NathanWalker commented on Aug 18, 2020

    @NathanWalker
    Contributor

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

  2. NathanWalker commented on Aug 18, 2020

    @NathanWalker
    Contributor

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

  3. denlysenko commented on Aug 19, 2020

    @denlysenko
    ContributorAuthor

    @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);
    }

  4. NathanWalker commented on Aug 19, 2020

    @NathanWalker
    Contributor

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

  5. denlysenko commented on Aug 19, 2020

    @denlysenko
    ContributorAuthor

    ok

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions