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

onDocumentClick not correctly de-registered #2154

Open
@mihneasim

Description

@mihneasim

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions