InfomediaLtd / angular2-materialize

Angular 2 support for Materialize CSS framework.
https://infomedialtd.github.io/angular2-materialize/
MIT License
406 stars 139 forks source link

Problem with Modal when used browser back navigation used #402

Open akashbiz opened 6 years ago

akashbiz commented 6 years ago

Hello, I have used materializecss modal in my angular2 project. I am facing an issue, when I open a modal and click on browser's back nagivation, popup gets close without executing close modal method written in component but overlay stay's at it is and website gets block. is there anything i am missing or have anyone face this issue before? This issue also replicates on Official Demo of Angular2-materialize, please check here https://infomedialtd.github.io/angular2-materialize/#/Dialogs

pain0486 commented 6 years ago

I generally set modals to open on there own named router-outlet. Here is an example Note: It does not work in the example as your browser will throw a security error, but it will work fine when your not running on stack-blitz or some plunker type site. You could try getting around this by using Chrome and running with the --allow-file-access-from-files flag. as detailed here

The code should give you an idea of how it works. I use this in our main application everywhere and I have no issues. The key is the ngOnDestroy method calls close on the modal when you navigate.