Skip to content

uiSrefActive should be also true for children states #887

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
jgrenon opened this issue Feb 14, 2014 · 1 comment
Closed

uiSrefActive should be also true for children states #887

jgrenon opened this issue Feb 14, 2014 · 1 comment

Comments

@jgrenon
Copy link

jgrenon commented Feb 14, 2014

In version 0.2.8-bowratic-tedium, if you use ui-sref-active with nested views, the active state is recorded only for the current state. When using nested views, it is logic for the parent state to still be active while in any of its children states.

In my project, I've applied this local quick modification with good results :

In angular-ui-router.js: 2454

  // Update route state
  function update() {
    if ($state.$current.self.name.indexOf(state.name) === 0 && matchesParams()) {
      $element.addClass(activeClass);
    } else {
      $element.removeClass(activeClass);
    }
  }

Instead of comparing state themselves, I make sure the state name begins with the same pattern, which by convention is the same or a child state.

Could you please apply the same logic (maybe with more error checking) to the next release? It doesn't break existing logic but provide a good logical enhancement.

@nateabele
Copy link
Contributor

#819

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

No branches or pull requests

2 participants