angularcalendarbootstrap-4bootstrap-modalbootstrap-datepicker

Mat-datepicker-toggle showing behind modal


Helloo, I have a problem on my view using angular 4 and bootstrap 4. When I click on open to show calendar. It's showing behind my modal. I want to change z-index on its class but i don't have acces to the class because it's auto-generated. How can i fix the probleme? enter image description here This is my code. enter image description here Thanks in advance.


Solution

  • The issue is that bootstrap-modal sets z-index:1050

    .modal {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 1050;
        display: none;
        overflow: hidden;
        -webkit-overflow-scrolling: touch;
        outline: 0;
    }
    

    The material date picker sets z-index: 1000 when the ckd-overlay-pane is created

    .cdk-overlay-pane {
        position: absolute;
        pointer-events: auto;
        box-sizing: border-box;
        z-index: 1000;
        display: flex;
        max-width: 100%;
        max-height: 100%;
    }
    

    Adding this to your component style sheet should do the trick... but this will apply to all date-pickers in your entire project.


    Please reference the answer on this SO question for why using ::ng-deep is ok until further notice.

    What to use in place of ::ng-deep