You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
If you have an mdAutoComplete on your page set with md-min-length="0", and your page in some way modifies the scope variable bound to the md-search-text attribute, it will trigger open the list of options to select from, even if the mdAutoComplete does not have the input focus. In addition, should you have code in your controller which sets the value of the scope variable in the context of a $timeout call (or some other delayed execution), even if you set it to an empty string, the list will open as well, even without the focus.
In the CodePen, I have simulated this by putting a simple $timeout call at the end of the controller definition which sets the scope variable to an empty string. You should see the list open automatically once the CodePen finishes loading, even though the focus is not on that element. In addition, if you set a value by clicking from the list, and then click the "Clear Search Text" button (which sets the scope variable to an empty string), it will again trigger the list opening.
Note: A simple workaround right now would be to change my code to set the scope variable to be undefined, rather than an empty string. However, this leads to an error being thrown by the function isMinLengthMet(), which is not desirable, and it would not solve the problem which occurs if other parts of my controller update that scope variable to a different value as that will open the list options again, even if not focused.
As I noted in the referenced issue by another user (#2767), perhaps a change in logic in the shouldHide function which not only checks the minimum length of the search text, but also checks to see if the input box has the focus, would resolve this (and other) problems.
The text was updated successfully, but these errors were encountered:
CodePen: http://codepen.io/londovir/pen/GJpdGR?editors=101
If you have an
mdAutoComplete
on your page set withmd-min-length="0"
, and your page in some way modifies the scope variable bound to themd-search-text
attribute, it will trigger open the list of options to select from, even if themdAutoComplete
does not have the input focus. In addition, should you have code in your controller which sets the value of the scope variable in the context of a$timeout
call (or some other delayed execution), even if you set it to an empty string, the list will open as well, even without the focus.In the CodePen, I have simulated this by putting a simple
$timeout
call at the end of the controller definition which sets the scope variable to an empty string. You should see the list open automatically once the CodePen finishes loading, even though the focus is not on that element. In addition, if you set a value by clicking from the list, and then click the "Clear Search Text" button (which sets the scope variable to an empty string), it will again trigger the list opening.Note: A simple workaround right now would be to change my code to set the scope variable to be
undefined
, rather than an empty string. However, this leads to an error being thrown by the functionisMinLengthMet()
, which is not desirable, and it would not solve the problem which occurs if other parts of my controller update that scope variable to a different value as that will open the list options again, even if not focused.As I noted in the referenced issue by another user (#2767), perhaps a change in logic in the
shouldHide
function which not only checks the minimum length of the search text, but also checks to see if the input box has the focus, would resolve this (and other) problems.The text was updated successfully, but these errors were encountered: