Nested Modal (Modal inside Modal) appears behind parent modal after Angular 21 + NG-ZORRO v21 migration
Reproduction link
[https://stackblitz.com/edit/ng-zorro-antd-start-1r6g4hie Steps to reproduce: 1. Add parent with [(nzVisible)]="parentFlag" 2. Inside parent modal content, add child with [(nzVisible)]="childFlag" 3. Open parent modal, then trigger child modal 4. Child modal appears BEHIND parent Cannot create full reproduction due to enterprise code restrictions, but issue is reproducible with basic nested modal structure shown above.](https://stackblitz.com/edit/ng-zorro-antd-start-1r6g4hie Steps to reproduce: 1. Add parent with [(nzVisible)]="parentFlag" 2. Inside parent modal content, add child with [(nzVisible)]="childFlag" 3. Open parent modal, then trigger child modal 4. Child modal appears BEHIND parent Cannot create full reproduction due to enterprise code restrictions, but issue is reproducible with basic nested modal structure shown above.)
Steps to reproduce
- Create parent modal using
<nz-modal [(nzVisible)]="parentFlag" nzWidth="1000px"> - Inside parent modal content, render a child component via selector
- In child component template, add another
<nz-modal [(nzVisible)]="childFlag" nzWidth="80%"> - Open parent modal from main screen
- Click element inside child component to trigger
childFlag = true - Observe child modal appears BEHIND parent modal instead of on top
What is expected?
Child modal should appear on top of parent modal with proper z-index stacking. User should be able to interact with child modal while parent modal remains in background. This worked correctly in Angular 19 NG-ZORRO v19.
What is actually happening?
Child modal renders behind parent modal and is not clickable. Both modals appear in .cdk-overlay-container with same z-index (1000). Browser stacks them by DOM creation order, not logical hierarchy.
Attempted fixes that did NOT work:
- Setting [nzZIndex]="2000" on child modal
- Setting [nzZIndex]="1000" on parent, [nzZIndex]="10001" on child
- Using NzModalService.create() (caused screen to be unclickable)
- Global CSS for .cdk-overlay-container z-index (broke other overlays)
Issue appeared after migrating from Angular 19 NG-ZORRO v19 to Angular 21 NG-ZORRO v21. Same code worked correctly in v19.
| Environment | Info |
|---|---|
| ng-zorro-antd | 21.0.2 |
| Browser | Chrome (latest) |
Cannot provide StackBlitz/CodeSandbox due to proprietary code restrictions.
Issue occurs with this structure:
- Parent modal (template-based) containing a child component
- Child component has its own modal (template-based)
- Both modals use default z-index (1000)
- Child modal opens BEHIND parent instead of on top
This worked in Angular 19 NG-ZORRO v19, broke after migrating to Angular 21 NG-ZORRO v21.
Source: NG-ZORRO/ng-zorro-antd