Angular: Dropdown menu closes too quickly after input loses focus

dmr07

I'm trying to build a search input with a dropdown menu attached to it. I have set the menu to close when the input box loses focus.

Problem: When I click on the links inside the dropdown menu, the menu closes even before any events are registered.

// Search input box
<input type="text" ng-blur="lostFocus()" eva-search />

// Dropdown menu
<div class="component-styleWrap"
     ng-click="$event.stopImmediatePropagation(); $event.stopPropagation()">
  <li>Example Link</li>
  <li>Example Link</li>
</div>
Buh Buh

If you just want to delay the effects of your call to lostFocus(), then a timeout should be enough.

app.controller("myController", function ($scope,  $timeout) {
    $scope.lostFocus = function () {
        $timeout(function () {
            //whatever your code needs to do goes here.
        }, 100);
     });
});

You shouldn't really need the 100 in there. I just added that to be on the safe side. Try it without the 100 if you can.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

dropdown closes on focus

From Dev

Input loses focus after the first character is entered, even with a key specified

From Dev

angularJS textAngular input box loses focus after entering text

From Dev

Input box focus after jQuery dropdown click

From Dev

keypresss event automatically fires after text input loses focus and gained focus again

From Dev

Parent loses focus on Kendo UI Context Menu

From Dev

Parent loses focus on Kendo UI Context Menu

From Dev

Dropdown closes after every click

From Dev

Dropdown closes after every click

From Dev

Angular :: Making Input Text to open up dropdown list upon focus

From Dev

Angular :: Making Input Text to open up dropdown list upon focus

From Dev

Make input readonly when it loses focus

From Dev

Nested React <input> element loses focus on typing

From Dev

Number input field loses focus on validation change

From Dev

Dropdown menu not working (tab focus)

From Dev

creating a dropdown menu when focus

From Dev

Hoverable Dropdown Menu closes once you hover over the Dropdown Menu

From Dev

Focus on Input when Bootstrap Modal closes

From Dev

CSS dropdown menu closes before I click

From Dev

JComboBox loses focus after typing one character

From Dev

After appending input field to a different container, I cannot continue typing in the text input unless I click again. It loses focus

From Dev

Menu dropdown list is too long

From Dev

Dropdown menu with keyboard input

From Dev

focus input after reloading

From Dev

IntelliJ IDEA Menu Popups Close too Quickly

From Dev

dropdown menu for angular

From Dev

Cannot give .focus() to an element of a dropdown menu

From Dev

Html input loses focus on Samsung Android when virtual keyboard appears

From Dev

Angular JS - Automatically focus input and show typeahead dropdown - ui.bootstrap.typeahead

Related Related

  1. 1

    dropdown closes on focus

  2. 2

    Input loses focus after the first character is entered, even with a key specified

  3. 3

    angularJS textAngular input box loses focus after entering text

  4. 4

    Input box focus after jQuery dropdown click

  5. 5

    keypresss event automatically fires after text input loses focus and gained focus again

  6. 6

    Parent loses focus on Kendo UI Context Menu

  7. 7

    Parent loses focus on Kendo UI Context Menu

  8. 8

    Dropdown closes after every click

  9. 9

    Dropdown closes after every click

  10. 10

    Angular :: Making Input Text to open up dropdown list upon focus

  11. 11

    Angular :: Making Input Text to open up dropdown list upon focus

  12. 12

    Make input readonly when it loses focus

  13. 13

    Nested React <input> element loses focus on typing

  14. 14

    Number input field loses focus on validation change

  15. 15

    Dropdown menu not working (tab focus)

  16. 16

    creating a dropdown menu when focus

  17. 17

    Hoverable Dropdown Menu closes once you hover over the Dropdown Menu

  18. 18

    Focus on Input when Bootstrap Modal closes

  19. 19

    CSS dropdown menu closes before I click

  20. 20

    JComboBox loses focus after typing one character

  21. 21

    After appending input field to a different container, I cannot continue typing in the text input unless I click again. It loses focus

  22. 22

    Menu dropdown list is too long

  23. 23

    Dropdown menu with keyboard input

  24. 24

    focus input after reloading

  25. 25

    IntelliJ IDEA Menu Popups Close too Quickly

  26. 26

    dropdown menu for angular

  27. 27

    Cannot give .focus() to an element of a dropdown menu

  28. 28

    Html input loses focus on Samsung Android when virtual keyboard appears

  29. 29

    Angular JS - Automatically focus input and show typeahead dropdown - ui.bootstrap.typeahead

HotTag

Archive