NG-ZORRO / ng-zorro-antd

Angular UI Component Library based on Ant Design
https://ng.ant.design
MIT License
8.87k stars 3.92k forks source link

@Output event not emitting from nzOnOk when modal is inside a component within a ng-template #8825

Open srizzon opened 2 weeks ago

srizzon commented 2 weeks ago

Reproduction link

https://stackblitz.com/edit/angular-yqmg18

Steps to reproduce

  1. Create a component and put it inside a ng-template.
  2. Add a button to trigger the modal within the template.
  3. Emit an @Output event in the nzOnOk method from the modal.
  4. The @Output event is not emitted as expected when the modal is inside a component that is inside a ng-template.

What is expected?

The @Output event from the nzOnOk should be emitted correctly even when the modal is inside a component that is inside a ng-template.

What is actually happening?

The @Output event does not trigger when the modal is placed inside a component within a ng-template.

Environment Info
ng-zorro-antd 18.1.1
Browser Brave
volvachev commented 1 week ago

In your example when you open a dialog popover is closed(and destroyed), because of this there are no subscribers to the Observable, which leads to non-obvious behavior. Modal has ref to destroyed component, without @output subscribers.