creativetimofficial / ct-paper-dashboard-pro-angular

8 stars 10 forks source link

[Bug] Angular 13 + Bootstrap 5 - Modal z-index #43

Open mrseanr opened 2 years ago

mrseanr commented 2 years ago

Version

1.5

Reproduction link

https://github.com/creativetimofficial/ct-paper-dashboard-pro-angular

Operating System

Mac OS Monterey

Device

2021 Macbook Pro (M1 Pro Chipset)

Browser & Version

Chrome v. 101.0.4951.41

Steps to reproduce

  1. download zip
  2. extract to folder
  3. open vs code
  4. npm install
  5. add the following to a module (app.module is fine)
  6. import {NgbModule} from '@ng-bootstrap/ng-bootstrap';
    ...
    imports: [
    ... 
    NgbModule,
    ...
    ],
  7. Enter the following on a component.html
    <button class="btn btn-lg btn-outline-primary" (click)="open(mymodal)">Open My Modal</button>
    <ng-template #mymodal let-modal>
    <div class="modal-header">
    <h4 class="modal-title" id="modal-basic-title">Bootstrap Modal</h4>
    <button type="button" class="close" aria-label="Close" (click)="modal.dismiss('Cross click')">
      <span aria-hidden="true">×</span>
    </button>
    </div>
    <div class="modal-body">
    This is example from Tutsmake.com
    </div>
    <div class="modal-footer">
    <button type="button" class="btn btn-outline-dark" (click)="modal.close('Save click')">Ok</button>
    </div>
    </ng-template>
  8. Use the necessary code from the following in the component.ts
    
    import { Component } from '@angular/core';

import {NgbModal, ModalDismissReasons} from '@ng-bootstrap/ng-bootstrap';

@Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'] }) export class AppComponent { title = 'appBootstrap';

closeResult: string = '';

/*------------------------------------------

Created constructor

--------------------------------------------*/ constructor(private modalService: NgbModal) {}

/**

  1. using the browser console, changing the z-index to 1050 shows the proper display Screen Shot 2022-05-02 at 3 09 04 PM

What is expected?

the modal backdrop is positioned behind the modal content

What is actually happening?

the modal content is effectively disabled due to the z-index


Solution

I added the following to the _modals.scss, which fixes the ngb-modal issue, but it breaks the OOB Paper Dashboard modals on the components/notifications pages

.modal-backdrop {
    z-index: 1050 !important;
}

Since this addition breaks the OOB modals, what is the better solution?

Additional comments