ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
51k stars 13.52k forks source link

bug: ionic 4 deal with modal when users click phone back button #20806

Closed yexinjia closed 4 years ago

yexinjia commented 4 years ago

What should happen when users click over back button of phone? In case when modal opens. Registered a back button:

// To prevent interference with ionic's own backbutton handling // you can subscribe with a low priority instead this.platform.backButton.subscribe(() => { // code that is executed when the user pressed the back button // and ionic doesn't already know what to do (close modals etc...) self.modalController.dismiss(); });

The problem with the code:

It closes/dismiss modal is fine!

But it also pushed back the page from where the modal is opened. Means it pop the page behind modal.

This should not happen the page should not pop - only modal should close.

liamdebeasi commented 4 years ago

Thanks for the issue. Can you provide a repo with the code required to reproduce this issue? The current behavior in Ionic Framework is to dismiss the active modals first before navigating backwards when pressing the hardware back button.

yexinjia commented 4 years ago

I dismiss the active modals first, but there is no effect.

liamdebeasi commented 4 years ago

Ionic Framework will take care of dismissing any active modals first, so the custom code you have written above is not needed. If you remove the custom code, does that resolve your issue?

yexinjia commented 4 years ago

on my phone, is no effect. Ionic Framework will take care of dismissing any but modal.

liamdebeasi commented 4 years ago

Can you provide a repo with the code required to reproduce this issue?

AlwaysLoveme commented 4 years ago

I wish when I click the back button do not close modal compoent, what should i do ? because there is a login page in Modal component, and my project must be to login to use.

AlwaysLoveme commented 4 years ago

Can you provide a repo with the code required to reproduce this issue?

I wish when I click the back button do not close modal compoent, what should i do ? because there is a login page in Modal component, and my project must be to login to use.

ionitron-bot[bot] commented 4 years ago

Thanks for the issue! This issue is being closed due to the lack of a reply. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Thank you for using Ionic!