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.

Typeahead z-index problem when used inside Modal

See original GitHub issue

Bug description:

When using container="body" on Typeahead, and placing Typeahead inside Modal, I am seeing the Typeahead’s dropdpown appear behind the Modal in the z-index order. (Typeahead dropdown z-index is 1000 while Modal is 1050).

Please see the attached Stackblitz.

Link to minimally-working StackBlitz that reproduces the issue:

https://stackblitz.com/edit/angular-7dfepa

  1. Open the modal by clicking “Launch Demo Modal”
  2. Interact with the first Typeahead (type “te”) - notice it works fine
  3. Interact with the second Typeahead (type “te”) - noticed there is no dropdown visible on the screen. Using Chrome Element Inspector we can see that the <ngb-typeahead-window> appended to body has a class of .dropdown-menu setting the z-index of 1000 (below the modal of 1050).
  4. Push down arrow key of keyboard, then enter key of keyboard, to select invisible 1st option of Typeahead.
  5. Interact with the Dropdown, notice it works correctly, this also is using container="body", I see a dynamically added z-index on the element style, presumably by ngb code.

Versions of Angular, ng-bootstrap and Bootstrap:

Angular: 9.1.0

ng-bootstrap: 6.1.0

Bootstrap: 4.3.0

Thanks

Thank you team, we ❤️ ng-bootstrap lib!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
FirstVertexcommented, Jun 18, 2020

As a temporary workaround, I am applying the following CSS at the global level

ngb-modal-window + ngb-typeahead-window.dropdown-menu {
    z-index: 1051;
}
0reactions
eliprandcommented, Jan 13, 2021

@benouat would you consider adding an option for a custom CSS class to be applied to that ngb-typeahead-window ? similar to the windowClass on the Modal control. With that, we could set the z-index on the typeahead inside our modal as-needed without having to influence all typeaheads as is the case with the workaround. I would be happy to work on the implementation if that’s something that could be considered. Merci 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bootstrap typeahead not Working inside the Bootstrap Modal
php and task. js but it seems that the typeahead is not working inside the bootstrap modal. $(document). ready(function(){ $("#assign_to").
Read more >
Bug - autocomplete dropdown lists now z-indexed behind modal
I finally updated from 3.2 to 3.7. 1, and now all autocomplete dropdown lists appear behind the modals they are in.
Read more >
Using Bootstrap's typeahead from inside a modal window
How you can go about using Bootstrap's typeahead in a modal window. ... in your text editor of choice and then add a...
Read more >
AutoComplete Z-Index Problem / Firefox - MSDN
I have set z-index both by using the CompletionListCssClass property, and by setting a z-index on the Id generated by asp.net for the...
Read more >
UI 04: Modal Implementation using position, z-index - Medium
UI 01: Autocomplete Implementation using Javascript, Html, CSS ... However, there is still a problem: The modal can not be displayed in the...
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