Multiple autocomplete elements with md-select-on-focus infinitely focuses and blurs.
Actual Behavior: I have multiple md-autocomplete components on a page, all with md-min-length="0" and md-select-on-focus.
What is the issue? *When I hold tab for a second or two, the focus keeps switching to the next element. But when I let go of the tab key, labels keep switching between selected and unselected for one or more autocomplete elements en dropdowns keep opening and closing. In my application this also happens sometimes when the user returns to the page and selects an autocomplete element (so no tab), but that is harder to reproduce, especially in a demo.What is the expected behavior?I expect that when I stop pressing tab, the selecting and blurring of autocomplete elements stops (perhaps not immediately, but at least pretty quick).
CodePen (or steps to reproduce the issue): *
CodePen Demo which shows your issue:http://output.jsbin.com/rabitabube EDIT: I just noticed preview doesn't work on jsbin after an hour, I am not sure how to keep the focus inside the output window in either jsbin or codepen. Open to suggestions.Details:Press tab for a second or two to see the bug. Demo in jsbin, because holding the tab left the output-window in codepen.
AngularJS Versions: *
AngularJS Version:1.6.4AngularJS Material Version:1.1.4 in demo, 1.1.5 in app
Additional Information:
Browser Type: *ChromeBrowser Version: *62OS: *Windows 10Stack Traces:none
Thank you for taking the time to submit this issue. In CodePen, you can select 'Change View' -> 'Full Page', or add /full/ to your CodePen URL. This will let you test without having the CodePen chrome in the way.
Here is another code-pen illustrating the issue with simple instructions to easily and consistently reproduce: https://codepen.io/jonbcard/pen/PQQwLG
A quick look at md-select-on-focus shows that the problem is with this block of code in onFocus():
$timeout(function() {
// Use HTMLInputElement#select to fix firefox select issues.
// The debounce is here for Edge's sake, otherwise the selection doesn't work.
element[0].select();
// This should be reset from inside the `focus`, because the event might
// have originated from something different than a click, e.g. a keyboard event.
preventMouseUp = false;
}, 1, false);
The problem is that element[0].select() retriggers focus for that element and we end up in an infinite loop with the two autocompletes competing for focus.
Fixed in https://github.com/angular/material/commit/c5ec316b2218f59058cb8b28f9585e70ce41eecd