material icon indicating copy to clipboard operation
material copied to clipboard

navbar: active tab not selected with ui-router

Open Liam-Tait opened this issue 7 years ago • 7 comments

Actual Behavior:

  • What is the issue? * md-nav-bar / md-nav-item does not select an active tab based upon the current ui-router
  • What is the expected behavior? When an md-nav-item links to the currently active route, that tab should be the selected tab by default. CodePen (or steps to reproduce the issue): *
  • CodePen Demo which shows your issue: http://codepen.io/liamtait/pen/pPoZMY
  • Details: When navigating to a route via a link, or refreshing the page after selecting a route, selected tab is not set to the current active tab Info gets lost on refresh and is never shown if the user follows a deep link. Leads to confusion and loss of place for the user.

navigating to http://s.codepen.io/liamtait/fullpage/pPoZMY?#/routeA does not select the routeA button

AngularJS Versions: *

  • AngularJS Version: 1.5.11
  • AngularJS Material Version: 1.1.3

Additional Information:

  • Browser Type: * Chrome
  • Browser Version: * 57.0.2987.133 (64-bit)
  • OS: * Windows 10
  • Stack Traces:

Shortcut to create a new CodePen Demo. Note: * indicates required information. Without this information, your issue may be auto-closed.

Do not modify the titles or questions. Simply add your responses to the ends of the questions. Add more lines if needed.

Liam-Tait avatar Apr 13 '17 05:04 Liam-Tait

+1 !!!!

stephengardner avatar May 02 '17 06:05 stephengardner

+1

benoitbc avatar May 03 '17 13:05 benoitbc

I brought this up on Stack Overflow and someone came up with a reasonable manual workaround.

This is something that should be integrated into mdNavBar, though, and in fact the documentation makes it sound like it already supports this. But it's not.

garretwilson avatar May 03 '17 13:05 garretwilson

I couldn't make it work by garretwilson example, but next setup helped:

<md-nav-bar md-selected-nav-item="$ctrl.currentNavItem" nav-bar-aria-label="navigation links">
        <md-nav-item ng-repeat="page in ::$ctrl.pages" md-nav-sref="{{::page.state}}" name="{{::page.name}}">{{::page.label}}</md-nav-item>
      </md-nav-bar>

And the controller (coffeescript):

panelController = (_, $timeout, $state, User, Routes) ->
  @pages = [
    state: Routes.tooltips
    name: 'tooltips'
    label: 'Helpers'
  ,
    state: Routes.events
    name: 'events'
    label: 'Events'
  ,
    state: Routes.users
    name: 'users'
    label: 'Users'
  ]

  $timeout =>
    @currentNavItem = _.find(@pages, state: $state.current.name).name

Paragonid avatar May 23 '17 09:05 Paragonid

+1

mdehghani avatar Jun 18 '17 11:06 mdehghani

@EladBezalel - let's get this one fixed for v1.1.5; if possible.

ThomasBurleson avatar Jun 18 '17 12:06 ThomasBurleson

+1! 👍

Logrythmik avatar Sep 06 '17 16:09 Logrythmik