question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

dropdown item keyboard selection with autoclose = true not happening

See original GitHub issue

Bug description:

  • click on drop down with autoClose = true
  • press arrow down
  • press enter current:
  • dropdown is closed while click handler of dropdown item was not fired expected
  • dropdown is closed and click handler of dropdown item was fired

selection works when autoclose is false.

dropdownbug

Link to minimally-working StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-6c8p1w?file=app/dropdown-manual.ts

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: reproduced on 8.0.0 and 7.1.3 ng-bootstrap: 4.2.1 Bootstrap: 4.3.1

excerpt from src/dropdown/dropdown.ts

...
    // closing on Enter / Space
    if (key === Key.Space || key === Key.Enter) {
      if (isEventFromItems && (this.autoClose === true || this.autoClose === 'inside')) {
        this.close();
      }
      return;
    }

    // opening / navigating
    if (isEventFromToggle || isEventFromItems) {
....

navigation is not happening when user press enter or space. Would you mind if I change it to allow navigation and close dropdown async if it required? I suppose without async closing dropdown item will disappear before click event fires.

upd found a workaround and added into the stackblitz. good enough for now.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
IAfanasovMobcommented, Jun 29, 2019

@kerbs17 it’s about selection using keyboard (: I see in the gif attached you use a mouse

0reactions
kerbs17commented, Jun 28, 2019

Interesting, I’m using your provided stackblitz url and it doesn’t work in Chrome, FF, or Safari on my Mac.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Avoid dropdown menu close on click inside - Stack Overflow
By default, the dropdown menu is closed when clicking inside or outside the dropdown menu. You can use the autoClose option to change...
Read more >
Dropdowns - Bootstrap
Dropdowns are toggleable, contextual overlays for displaying lists of links and more. They're made interactive with the included Bootstrap dropdown ...
Read more >
Dropdowns | React-Bootstrap
By default, autoClose is set to the default value true and behaves like expected. By choosing false , the dropdown menu can only...
Read more >
Select does not open dropdown onclick | Firefox Support Forum
We found that the problems root was inside the fact that the datepicker was inside a colorbox modal. We avoided the issue by...
Read more >
Customize a reusable React dropdown menu component
But just by looking the code, I saw that it is not working as it should. A custom select should be accessible through...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found