Skip to content
This repository was archived by the owner on Sep 5, 2024. It is now read-only.
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

Closed

Description

@jgoux

Steps to reproduce the bug :

I'm on the master and my browser is Chrome v43

Activity

  1. DrDanRyan commented on Jun 16, 2015

    @DrDanRyan

    This issue also occurs if you select an item, and then backspace to delete the input to an empty state and then click away

  2. kschwidder commented on Jun 16, 2015

    @kschwidder

    +1
    This is a major bug which blocks sites. Please provide a fix if possible.

  3. tolemac commented on Jun 18, 2015

    @tolemac

    +1

  4. sonya-s commented on Jun 18, 2015

    @sonya-s

    +1

  5. GautierT commented on Jun 18, 2015

    @GautierT

    +1 freezing the chrome tab.

  6. SimeonC commented on Jun 24, 2015

    @SimeonC

    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.

  7. charliewynn commented on Jun 25, 2015

    @charliewynn

    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 😄

  8. vlad-lifliand commented on Jun 25, 2015

    @vlad-lifliand

    +1

  9. gitawego commented on Jun 26, 2015

    @gitawego

    same here.

  10. sricc commented on Jun 26, 2015

    @sricc

    +1

  11. mwymann commented on Jun 29, 2015

    @mwymann

    +1

  12. patzick commented on Jun 29, 2015

    @patzick

    +1

    temporary css workaround
    .md-scroll-mask
        position: initial
  13. jozsi commented on Jun 29, 2015

    @jozsi

    +1

  14. GuruM commented on Jul 2, 2015

    @GuruM

    +1

  15. added this to the 0.10.1 milestone on Jul 2, 2015
  16. 49 remaining items

  17. S8nsick66 commented on Mar 31, 2016

    @S8nsick66

    Thank you @vshanbha, that works.

    setTimeout(
        function(){
            $state.go(state.url, state.params, {
                location: true,
                reload: true,
                inherit: true
            })
        }, 50);

    This was my first attempt, it works too.

    var url = $state.href(state.name, state.params, {absolute: true});
    $window.location.href = url;
  18. mzaarour commented on Jul 29, 2016

    @mzaarour

    +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

  19. mzaarour commented on Jul 29, 2016

    @mzaarour

    Temp solution : Put this lines into your function which hide the md-autocomplete

    //Patch for autocomplete which doesn't remove
    angular.element('body')[0].style = '';
    if(angular.element('.md-scroll-mask')[0])
        angular.element('.md-scroll-mask')[0].remove();
  20. leibale commented on Aug 10, 2016

    @leibale
    Contributor

    what about this?

  21. uocnb commented on Sep 14, 2016

    @uocnb

    Got same problem with smDateTimeRangePicker, tried to remove .md-scroll-mask already 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

  22. jlamarr22 commented on Oct 6, 2016

    @jlamarr22

    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; }

  23. jithureddy commented on Mar 21, 2017

    @jithureddy

    Looks like this issue fixed in latest version of angular material for desktops but not for touch devices
    #10521. How to handle this

  24. madchops1 commented on Jun 6, 2017

    @madchops1

    Where we at with this?

  25. orenagiv commented on Jun 28, 2017

    @orenagiv

    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:

    .md-scroll-mask {z-index:0!important}
  26. frame commented on Sep 20, 2018

    @frame

    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-mask div.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.

    function onResultsRetrieved(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 destroyed
    
      handleResults(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();
         }
  27. Splaktar commented on Sep 20, 2018

    @Splaktar
    Contributor

    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.

  28. locked as resolved and limited conversation to collaborators on Sep 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions