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.
Repository navigation
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
md-autocomplete: unable to click/focus on anything after a click on the "clear" button #3287
To add to this - this seems to occur on the third consecutive click, if you use arrow keys + enter to select this doesn't occur.
If you click the autocomplete, click a selection, then click clear it locks up. I've recorded a video demonstrating here - http://screencast.com/t/NYkj14IYG9F
When we say "locks up" what is actually happening is that the <div class="md-scroll-mask"> is not being removed at some point and when you click the element it doesn't remove either.
in 0.10.0 I commented out line 12469 if angular-material defineProperty('hidden', handleHiddenChange, true);
and the function at 12642 handleHiddenChange (probably redundant to do the 2nd thing)
And it seems to be working for me.. Not sure what horrible thing I'm missing out on without the element 'hiding', but at least my app doesn't lock up 😄
+1
This happen
1- when you open an element such as auto complete element (can be date picker),
2- then the scroll of the container disapear, which is, i think the "normal" behaviour of the element.
3- Event occurs to hide the element (ie with ng-if which delete it to the dom) before it finishes it closes, the element won't have time to put newer the scroll
Result ==> the app freezes, should refresh the page to make it work again
Temp solution : Put this lines into your function which hide the md-autocomplete
//Patch for autocomplete which doesn't removeangular.element('body')[0].style='';if(angular.element('.md-scroll-mask')[0])angular.element('.md-scroll-mask')[0].remove();
What about just hiding the button with css? Seems to be working properly without it there and then you can create a custom button to set the value of the autocomplete back to blank.
I'm using v1.1.4 and I can reproduce this on Safari as well as Chrome (with or without the floating label).
On Chrome is causes a double click on the clear-button to release the suggestions container and then clear the search text.
On Safari the clear-button does not work at all, unless md-scroll-mask is out of the way.
I found the culprit: After the destruction of the autocomplete instance, its queued promises might still be running in the background. Once the promise gets finally resolved, onResultsRetrieved() gets triggered and inserts partially broken markup: div.md-scroll-maskdiv.md-visually-hidden and md-virtual-repeat-container all end up under <body>, regardless if the user already blurred the element and moved on.
The often mentioned fix to manually delete .md-scroll-mask after a timeout is just a lucky hit because the async call might run for a long time and onResultsRetrieved() will pollute your markup shortly after.
functiononResultsRetrieved(matches){cache[term]=matches;// Just cache the results if the request is now outdated.// The request becomes outdated, when the new searchText has changed during the result fetching.if((searchText||'')!==($scope.searchText||'')){return;}// TODO: Also return if the instance was abandoned or destroyedhandleResults(matches);}
The proper fix must detect if the original instance was abandoned or destroyed and return, similar if searchText was empty.
In my case I was able to solve this by simply emptying searchText on cleanup(), however this solution might not apply to everyone that's why I didn't create a PR.
--- angular-material.js+++ angular-material-clearSearchText.js@@ -25930,6 +25930,7 @@
* Removes any events or leftover elements created by this controller
*/
function cleanup () {
+ $scope.searchText = '';
if (!ctrl.hidden) {
$mdUtil.enableScrolling();
}
Activity
DrDanRyan commentedon Jun 16, 2015
This issue also occurs if you select an item, and then backspace to delete the input to an empty state and then click away
kschwidder commentedon Jun 16, 2015
+1
This is a major bug which blocks sites. Please provide a fix if possible.
tolemac commentedon Jun 18, 2015
+1
sonya-s commentedon Jun 18, 2015
+1
GautierT commentedon Jun 18, 2015
+1 freezing the chrome tab.
SimeonC commentedon Jun 24, 2015
To add to this - this seems to occur on the third consecutive click, if you use arrow keys + enter to select this doesn't occur.
If you click the autocomplete, click a selection, then click clear it locks up. I've recorded a video demonstrating here - http://screencast.com/t/NYkj14IYG9F
When we say "locks up" what is actually happening is that the
<div class="md-scroll-mask">is not being removed at some point and when you click the element it doesn't remove either.charliewynn commentedon Jun 25, 2015
in 0.10.0 I commented out line 12469 if angular-material
defineProperty('hidden', handleHiddenChange, true);and the function at 12642
handleHiddenChange(probably redundant to do the 2nd thing)And it seems to be working for me.. Not sure what horrible thing I'm missing out on without the element 'hiding', but at least my app doesn't lock up 😄
vlad-lifliand commentedon Jun 25, 2015
+1
gitawego commentedon Jun 26, 2015
same here.
sricc commentedon Jun 26, 2015
+1
mwymann commentedon Jun 29, 2015
+1
patzick commentedon Jun 29, 2015
+1
temporary css workaround
jozsi commentedon Jun 29, 2015
+1
GuruM commentedon Jul 2, 2015
+1
49 remaining items
S8nsick66 commentedon Mar 31, 2016
Thank you @vshanbha, that works.
This was my first attempt, it works too.
mzaarour commentedon Jul 29, 2016
+1
This happen
1- when you open an element such as auto complete element (can be date picker),
2- then the scroll of the container disapear, which is, i think the "normal" behaviour of the element.
3- Event occurs to hide the element (ie with ng-if which delete it to the dom) before it finishes it closes, the element won't have time to put newer the scroll
Result ==> the app freezes, should refresh the page to make it work again
Hope this can help fix the problem
mzaarour commentedon Jul 29, 2016
Temp solution : Put this lines into your function which hide the md-autocomplete
leibale commentedon Aug 10, 2016
what about this?
uocnb commentedon Sep 14, 2016
Got same problem with
smDateTimeRangePicker, tried to remove.md-scroll-maskalready but it back after open and close another menu 2 or 3 times.Tried with versions: 1.0.9, 1.0.10, 1.1.1
jlamarr22 commentedon Oct 6, 2016
What about just hiding the button with css? Seems to be working properly without it there and then you can create a custom button to set the value of the autocomplete back to blank.
md-autocomplete-wrap button[ng-click="$mdAutocompleteCtrl.clear($event)"] { display:none; }jithureddy commentedon Mar 21, 2017
Looks like this issue fixed in latest version of angular material for desktops but not for touch devices
#10521. How to handle this
madchops1 commentedon Jun 6, 2017
Where we at with this?
orenagiv commentedon Jun 28, 2017
I'm using v1.1.4 and I can reproduce this on Safari as well as Chrome (with or without the floating label).
On Chrome is causes a double click on the clear-button to release the suggestions container and then clear the search text.
On Safari the clear-button does not work at all, unless md-scroll-mask is out of the way.
Workaround - using CSS:
frame commentedon Sep 20, 2018
I found the culprit: After the destruction of the autocomplete instance, its queued promises might still be running in the background. Once the promise gets finally resolved,
onResultsRetrieved()gets triggered and inserts partially broken markup:div.md-scroll-maskdiv.md-visually-hiddenandmd-virtual-repeat-containerall end up under<body>, regardless if the user already blurred the element and moved on.The often mentioned fix to manually delete
.md-scroll-maskafter a timeout is just a lucky hit because the async call might run for a long time andonResultsRetrieved()will pollute your markup shortly after.The proper fix must detect if the original instance was abandoned or destroyed and return, similar if searchText was empty.
In my case I was able to solve this by simply emptying searchText on
cleanup(), however this solution might not apply to everyone that's why I didn't create a PR.Splaktar commentedon Sep 20, 2018
1.1.5 includes some additional fixes for related issues. baa869a contains some of these fixes. It comes from PR #10821.
If you are seeing issues after 1.1.5, please open a new issue with a CodePen reproduction.