-
Notifications
You must be signed in to change notification settings - Fork 3.4k
nav-bar: clicking a tab causes focus to move to a previously selected tab #11591
Comments
Your codepen is not valid, but this is reproducible in the docs here https://material.angularjs.org/latest/demo/navBar |
Looks like this is a regression introduced in 1.1.11 This is the commit that introduced the regression: 4d29450 |
I've Isolated this to a unit test, now working on a fix. This is actually a difficult issue, it looks like the focus handling is fired immediately, but there are a bunch of timeouts on updating the actual state of the tabs so we have to wait for that to complete before setting focus. It also looks like the updating functionality is called inside of a timeout and then internally it also calls a bunch of timeouts. EDIT: This completely fixes the issue and I absolutely cannot see anything wrong with this 20 timeouts didn't seem to do the trick, but 30 works great. (Obviously this is a joke, please don't do this) Still working on an elegant solution, hopefully I'll have more luck tomorrow. |
Okay thank you |
Thank you for taking the time to submit this issue. However it does not follow our required issue template. Providing a CodePen demo or link to a demo in the docs along with reproduction steps is required. This gives the team the information needed to investigate the bug or prioritize the feature. Please provide reproduction steps as I do not see an issue with the existing demo. Note that pressing the arrow keys only moves the focus, it does not change the tab selection. You need to press the space bar for the tab to be selected. Also note that the focus is indicated by the darker background and the selection is indicated by the colored label and inkbar. |
OK, thank you, it is helpful to know that clicking the mouse is required to reproduce this issue. It looks like in |
I have a branch that isolates this into a test and part of a fix prepared, I'll probably be able to wrap it up tonight. |
@codymikol awesome, thank you for looking into this! |
@codymikol any progress on this? Do you want me to take a look at what you have so far? |
add a $timeout that will allow enough time for the click event to complete so the focus event can properly evaluate Fixes: angular#11591
@Splaktar That should fix it. It's really strange, apparently there is just a significant delay from when focus events are fired to when click events are fired. |
add a $timeout that will allow enough time for the click event to complete so the focus event can properly evaluate Fixes: angular#11591
PR #11600 takes a different approach at fixing this w/o an extra timeout. Please take a look. |
<!-- Filling out this template is required! Do not delete it when submitting a Pull Request! Without this information, your Pull Request may be auto-closed. --> ## PR Checklist Please check that your PR fulfills the following requirements: - [x] The commit message follows [our guidelines](https://github.com/angular/material/blob/master/.github/CONTRIBUTING.md#-commit-message-format) - [x] Tests for the changes have been added or this is not a bug fix / enhancement - [x] Docs have been added, updated, or were not required ## PR Type What kind of change does this PR introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [x] Bugfix [ ] Enhancement [ ] Documentation content changes [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Build related changes [ ] CI related changes [ ] Infrastructure changes [ ] Other... Please describe: ``` ## What is the current behavior? Clicking on nav items with a mouse causes the focus to move to the previously clicked nav item instead of the newly clicked nav item. <!-- Please describe the current behavior that you are modifying and link to one or more relevant issues. --> Issue Number: Fixes #11591. Relates to #11494. Closes #11598. ## What is the new behavior? - Focus is moved to the new nav item after it is clicked. - remove hover style that is inconsistent with spec - add test from @codymikol ## Does this PR introduce a breaking change? ``` [ ] Yes [x] No ``` <!-- If this PR contains a breaking change, please describe the impact and migration path for existing applications below. --> <!-- Note that breaking changes are highly unlikely to get merged to master unless the validation is clear and the use case is critical. --> ## Other information Thank you to @codymikol for doing the initial investigation into this regression!
Detailed Reproduction Steps:
https://material.angularjs.org/latest/demo/navBar
What is the expected behavior?
md-nav-bar focus remove on previously selected nav-item
What is the current behavior?
md-nav-bar focus shows on previously selected nav-item
Which versions of AngularJS, Material, OS, and browsers are affected?
Is there anything else we should know? Stack Traces, Screenshots, etc.
https://material.angularjs.org/latest/demo/navBar
The text was updated successfully, but these errors were encountered: