-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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
Tabs does not respect setting selectedIndex #687
Comments
Sounds like a bug @robertmesserle |
@iainmckay I'm working on a fix for this, but wanted to explain why the bug exists. When you initially include tabs, you use a one-way binding in order to pass your When you click around inside of tabs, this changes the internal value for When you attempt to change tabs by setting your component value for In order to fix this, currently, you would have to keep a reference to the <md-tab-group [selectedIndex]="selectedIndex" #tabGroup> ... </md-tab-group>
<button (click)="tabGroup.selectedIndex = selectedIndex">Reset index</button> Another option (which is what I am working on adding) is to use a two-way binding so that your local <md-tab-group [(selectedIndex)]="selectedIndex"> ... </md-tab-group>
<button (click)="selectedIndex = 0">Reset index</button> Hopefully that makes sense. |
@robertmesserle Thank you very much for the in-depth response, this was the conclusion we came to also. |
why cant you put this in documentation? Getting activeTabIndex is most basic requirements for tabs. Somehow i find that documentation of google is always incomplete. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
…ar#705) Fixes angular#686 ,closes angular#687, fixes angular#550 - fix docs-api layouts to work down to 360px width - fixes Observers, Accessibility, Drag and Drop, Platform, and Overlay layouts - fix DeprecatedconnectedTo to Deprecated connectedTo display issue - update footer copyright - fix exception trying to unsubscribe to undefined routeParamSubscription - change how sidenav is closed on mobile after selecting a nav item
We have an md-tab-group with a number of md-tabs and we're setting an initial selected tab using the
selectedIndex
property and the user can then select to reset back to that initial tab. The problem we're finding is that if the user navigates using the labels to other tabs then chooses to reset back to the initial tab it doesn't work.We've traced through and we can see that
selectedIndex
is never updated by the tab component when the user selects other tabs, so when we try to setselectedIndex
back to the initial value, the angular change detection kicks in and says nothing changed.We know this is early days but is this behaviour expected to change? Can we submit a PR to fix it? Or is there a rationale for it being this way?
The text was updated successfully, but these errors were encountered: