ionic-framework: Android: Back button not dismissing modals

Short description of the problem:

I wrote an app with a modal that is expected to be dismissed with either its own “cancel” button or the hardware back button. However since an upgrade to Ionic 2.0.0 RC 1, it couldn’t be dismissed with the hardware button, but will quit within several presses with the modal present instead. If I manually dismiss the modal after pressing the back button, I could find that the page present is different from the one I opened the modal with, but some previous page.

Nor do hardware back buttons dismiss loading indicators.

What behavior are you expecting?

As in Ionic 2.0.0 Beta 10 and 11 (forgotten what happened on RC 0), the modal is dismissed with the hardware back button pressed.

Steps to reproduce:

  1. Write an app with a modal
  2. Build and run it
  3. Open that modal
  4. Press the hardware back button and see what would happen.

Which Ionic Version? 1.x or 2.x 2.0.0 RC 1

Run ionic info from terminal/cmd prompt: (paste output below)

Your system information: 

Cordova CLI: 6.3.0
Ionic Framework Version: 2.0.0-rc.1
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS:
Node Version: v6.3.1

Android 4.4.4

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 13
  • Comments: 76 (22 by maintainers)

Most upvoted comments

@Fdom92 @yannbf @Kobzol @dylanvdmerwe thanks a lot for your time! take a look! sidemenu and modal are fixed! https://www.dropbox.com/s/ybkcccdb2yiycvd/hardware_button.mov?dl=0

Hey there folks! Just to chime in on this.

We’re sorry that the team has been quiet lately. The fact is, we’ve been going through the entire core of the framework and rewriting it to use web components. This has been our main focus for the past few months and I’m confident you are going to love it when it’s ready (soon!).

While the rework is going well, we do notice that issues keep coming through at a rate that makes it hard to triage and focus on work on the framework at the same time. So we’ve made the decision to “freeze” ionic until we can get V4 out. While this is a tough thing to do and is a difficult decision, it is needed as we the team need to focus on the new release, which will address many of the outstanding issue (like virtual scroll).

Ok, so what are you going to do about this in the future?

Great question 😄 ! We’re reworking our process of dealing with issues and introducing a Bot to help automate a lot of this. This means that we’ll get to a point where we can respond to issues and have all of the information/data needed in order to debug and fix the issue. This so far has been the biggest pain point when dealing with Github’s current issue process. We’re very hopeful that this bot will improve our process and help resolve issues much quicker!

We’ll be releasing our updates on the whole process on our blog, so please keep an eye out for it.

To wrap up…

  • We’re sorry we’ve been silent and not responding to issues. We’re actively working to improve this process.
  • We’re NOT abandoning the project. We’re doubling down on our efforts to better manage things!

If you have any question/concerns, please feel free to send me an email. mike at ionic dot io

Cheers!

@amility: no one from Ionic team will reply to you here. They stopped addressing the community ages ago. Advice is to work around the bug as they clearly won’t fix it. Even better, choose a different framework like Flutter before you get too far down dev in your app.

Is this expected behavior with modals being separate from the main nav?

This is definitely not expected behaviour, it’s really confusing behaviour! 😄

Not fixed even in RC2…

@Fdom92 olee! that’s right! I am from Spain 😃

Yeah! It was already merged in master, so it will part of the next release!

Fixed! dec-02-2016 10-20-39

@manucorporat assign a milestone and fix the problem please. This behavior is annoying and confusing as everybody here reporting the problem knows.

The system Back button is used to navigate, in reverse chronological order, through the history of screens the user has recently worked with. It is generally based on the temporal relationships between screens, rather than the app’s hierarchy.

Android source: https://developer.android.com/design/patterns/navigation.html

If we agree that a modal is a “screen”, than it means that the hardware back button should close modals too.

Furthermore, in all the examples listed in the above listed documentation, the hardware back button is never displayed as triggering backs in the background of an opened screen.

So more than just the UIX behavior I may have been excepted, I think that this should be improved to fits the Android guidelines.

Thx in advance for finding an awesome solution as you always do Ionic team 😉

Exactly, on device it will close the app depending if ‘navExitApp’ config is true. But in the browser it just does nothing. BTW, here’s the commit: https://github.com/driftyco/ionic/commit/8de253a9b1216c64eba53e87ca96febb72de42f0

It is already in master, expecting to release a new nightly today.

There’s already an issue for multiple backbutton issues on Android here (#7611), although there’s no activity there.

It will be appreciated if you include this issue too #7611. There are another issues about the back button, for example, the side menu is not getting closed when the back button is pressed.

thx @manucorporat and ionic team for working on it and adding a milestone 👍

I have to chime in here. Unfortunately this is a serious issue and needs fixing. There is no possible good reason why the back button shouldn’t close a modal. It literally makes no sense. This issue is an absolute deal breaker for pushing apps live and needs to be prioritised above style fixes and other component enhancements please.

Not fixed even in RC3…

Is this ever going to be discussed for a fix? RC2 at the moment, and this behavior is the same since I started developing, back in Beta11. I personally think it’s not supposed to be an expected behavior, it’s rather weird. I have tested every app in my phone and used back button on modals and they all dismissed, rather than popping the nav of the page underneath it.

@daveshirman yes and no. For modals it is a regression bug, for not-closing-menu-on-back-button it is how driftyco guys see it, for custom alert confirmation on particular pages it is not a bug, but customization (what the backbutton handler is in the first place for).

If you will need to have a custom back button you will end up with similar approach independently of weather there is a bug in modal or not. Unless ionic2 will have some more generic mixing action handling back button (current priority on back button actions does not work for this at all).

Here is one example of register back button, that handles everything: https://github.com/driftyco/ionic/issues/6982#issuecomment-254740855

I didn’t say that. I just think their support and quality control is lousy at the moment and has been for a while. Feel free to take a look at my open issues, notice the date posted and lack of replies, from even the simplest of things.

Take a glance at how many issues there are here with Virtual Scroll. No replies. These are basic things in the framework that should just work.

Just my two cents.

On 7 Mar 2018 9:15 am, “amility” notifications@github.com wrote:

Really? Ionic team stopped supporting their project. Its quite unbelievable as I can still see their recent replies on latest closed issues.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ionic-team/ionic/issues/8692#issuecomment-371073834, or mute the thread https://github.com/notifications/unsubscribe-auth/ANnlXsGwJVyMqFrBZIQ1nqr5WJOUeyrTks5tb6U6gaJpZM4KWsVK .

@manucorporat I’m sorry for briging this up again, but in your fix, does the back button also happen to dismiss an ion-date picker? I just noticed that if I bring up the date picker and press back, it pops the page rather than dismiss the picker.

I know it’s not related to modal, but still, perhaps it’s an easy thing using the fix you’ve developed for modals/sidemenu.

Thanks!

@manucorporat i think it should close only the sidemenu. You can see it in gmail app, you open the sidemenu and when you press backbutton only close the sidemenu.

Only closing the menu seems reasonable to me, this is the behaviour that I see with pretty much any Android app using the drawer menu.

@NeoLSN sorry, but that just doesn’t make sense.

The back button is a system button. Its purpose is to go back a screen. Every Android app that I use dismisses modal screens when pressing the system (hardware/software) back button.

If anything, it should be TRUE by default with an option to set to FALSE to force interaction with the modal. But personally I don’t even see that it should be an option.

Just trying to make the case clearer for the Ionic team here.

Issue still exists in RC 3

@jgw96 Certainly not, if you mean “conforming to the corresponding platform’s recommended behavior for apps” by “expected”. In native Android/WP apps, the hardware back button is intended to be used to dismiss modals if present. Popping up the underlying page without dismissing the modal only makes the whole app confusing.

i think it is related with modal not having a ion-nav of its own again.