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.

Datepicker z-index problem inside modal

See original GitHub issue

When you put the boostrap datepicker inside a boostrap modal, the popup shows behind the modal.

This occurs because the code assumes the first element as the bigger zIndex inside the place function:

  var zIndex = parseInt(this.element.parents().filter(function(){
        return $(this).css('z-index') !== 'auto';
  }).first().css('z-index'))+10;

The FIX:

Iterate over all parents to discover the biggest zIndex:

Here is my code:

        var biggestZIndex = 0;
        this.element.parents().each(function(index, parent) {
            var zIndex = $(parent).css('z-index');
            if (zIndex !== 'auto') {
                var zIndex = parseInt(zIndex);
                if (zIndex > biggestZIndex) {
                    biggestZIndex = zIndex;
                }
            }
        });
        var zIndex = biggestZIndex + 10;

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

10reactions
carlituxmancommented, Nov 4, 2014

I fix it temporally with:

.datepicker{z-index:9999 !important}

0reactions
eviltek2099commented, Apr 9, 2019

I fixed with ul.uib-datepicker-popup.dropdown-menu.ng-scope { z-index: 1090 !important; }

Read more comments on GitHub >

github_iconTop Results From Across the Web

Datepicker on Modal (z-index) - Stack Overflow
I don't see any other reason why the date picker would not show inside the modal. I guess we need more details. If...
Read more >
10569 (Incorrect z-index position of Datepicker in some cases)
This means modal window has z-index equals 1050, but modal's parent DIV has z-index equals 1060! The cause of the incorrect z-index of...
Read more >
DatePicker problem in modal window and a solution
To use the DatePicker in modal windows causes some problems with the z-Index. First the DatePicker produces scrollbars if the modal window ist...
Read more >
Datepicker in modal with higher z-index than animation ...
Hi,. Ran in to an issue here. To avoid modals getting hidden behind animation containers, we use a class for a div and...
Read more >
Getting a calendar to display infront of a modal - Laracasts
... for my datepicker. The issue I'm having is that when I open up the calendar, the calendar ends up being hidden inside...
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