Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upbug(Mat Tabs): focusChange event does not fire when selecting first tab #20374
Comments
|
Confirmed that this is happening. I think this should be relatively simple to fix. |
crisbeto
added a commit
to crisbeto/material2
that referenced
this issue
Aug 21, 2020
We were always defaulting the `focusIndex` to 0 on init, rather than taking the index of the selected tab. We actually had tests for this behavior, but they were all testing against 0 so we never caught the issue. Fixes angular#20374.
crisbeto
linked a pull request that will
close
this issue
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment


Reproduction
https://stackblitz.com/edit/angular-yrahxe?file=src%2Fapp%2Ftab-group-basic-example.html
Steps to reproduce:
Expected Behavior
focusChange event should fire when a tab is changed regardless of initially selected tab (index) as a focus change occurred.
Actual Behavior
focusChange event does not fire if first tab is selected as internally it seems to assume the focus is on the first tab. For example, start on selectedIndex = 1 and clicking second tab will fire the event.
Potential Cause & Fix
It seems that in paginated-tab-header.ts, on initialization the initially active item is always 0. Since we should have access to the selectedIndex by this point, setting the following may address this problem.
this._keyManager.updateActiveItem(this._selectedIndex);Environment