Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

onDocumentClick not correctly de-registered #2154

Open
mihneasim opened this issue Aug 8, 2018 · 0 comments
Open

onDocumentClick not correctly de-registered #2154

mihneasim opened this issue Aug 8, 2018 · 0 comments

Comments

@mihneasim
Copy link

mihneasim commented Aug 8, 2018

Bug description:

Dropdown opens and closes when re-entering a view which renders ui-select. Root cause: onDocumentClick is not correctly de-registered.

Link to minimally-working plunker that reproduces the issue:

Version of Angular, UI-Select, and Bootstrap/Select2/Selectize CSS

Angular: 1.6

UI-Select: 0.19.8

Bootstrap/Select2/Selectize CSS (if applicable): "angular-ui-bootstrap": "2.5.0"

I changed the code accordingly in select.js for debugging purposes:

        function onDocumentClick(e) {
          console.log('onDocumentClick:', e.target, '$scope.open:', $select.open);
    ..

if i enter/exit 4 times the view which uses ui-select, and i click once in an element, i will get 3 onDocumentClick triggered for (e.target) and once for the actual clicked element, see screenshot -

screenshot 2018-08-08 14 32 08

which is not what one would expect given that we do de-register the delegated event handler on scope $destroy:

        $document.on('click', onDocumentClick);

        scope.$on('$destroy', function() {
         $document.off('click', onDocumentClick);
        });
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant