shlomiassaf / ngx-modialog

Modal / Dialog for Angular
http://shlomiassaf.github.io/ngx-modialog
MIT License
686 stars 241 forks source link

For inElement(true), should a click outside the dialog's backdrop cause the dialog to be dismissed? #422

Open kuhlschrank opened 6 years ago

kuhlschrank commented 6 years ago

Bug - I think

inElement-dialog is dismissed when clicking anywhere on the document - not just when clicking the backdrop

http://plnkr.co/edit/aMP3kmyEK4AwnOacrIyr?p=preview

In this plunker:

  1. click "Alert" for the top div
  2. dialog opens in top div
  3. click anywhere on the bottom div (not the "Alert" button)
  4. dialog of top div is dismissed

Dialog of top div should not be dismissed

We need multiple dialogs in multiple divs open at the same time

I found that the click listener for the backdrop dismissal is registered on the document itself

https://github.com/shlomiassaf/ngx-modialog/blob/master/src/ngx-modialog/src/overlay/overlay.component.ts#L182

this might be correct - but inside the registered handler it is never checked if the path of the click event contains the backdrop of the current dialog.

I think the backdrop should be dismissed only when the click was within the boundaries of the backdrop

kuhlschrank commented 6 years ago

Can someone at least tell me if I am correct in assuming that the behaviour I suggested is correct? Should the dialog stay open if a click was made outside the dialog's parent?

If so, I will gladly give it a try to implement my change and submit a PR!