Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ionic 2 backbutton issues with Android #7611

Closed
4 tasks done
jgw96 opened this issue Aug 8, 2016 · 15 comments
Closed
4 tasks done

Ionic 2 backbutton issues with Android #7611

jgw96 opened this issue Aug 8, 2016 · 15 comments
Assignees
Milestone

Comments

@jgw96
Copy link
Contributor

jgw96 commented Aug 8, 2016

Short description of the problem:

There are a few places where the back button behaves differently in an Ionic 2 app than in a native android app. This is a continuation of the discussion we had in our team meeting this morning.

  • In a native app when you have the sidemenu open and tap the back button it closes the sidemenu instead of closing the app. In ionic 2 it closes the app
  • In a native app with a sidemenu when you navigate to another page that is not the "home" page and then tap the back button it takes you back to the "home" page. Ionic 2 simply closes the app.
  • In a native app with tabs (youtube) no matter what tab you navigate too the back button will close the app. Currently in Ionic 2 we navigate back to the first tab when the back button is pressed.
  • Some users have expressed the desire to be able to stop the back button from closing the app in the situation where pressing the back button should close the app. I have mixed feelings about this as its generally considered bad ux to prevent a default operating system action and can seem "spammy" to stop an app from closing. Then again, I am not a ux expert 😄 .

Which Ionic Version? 2.0.0-beta.11

@jgw96 jgw96 removed the menus label Aug 8, 2016
@jephtta
Copy link

jephtta commented Aug 9, 2016

I am glad you brought this up. We've been building an app with ionic 2 for a while now, and have been conducting usability tests with a number of people; mostly university students who use android. Every single one of them (literally) is always confused about the behaviour of the back button. As far as my team is concerned, we see no advantage to the current behaviour since no one expects it.
As for the last point, if tapping the back button is supposed to close the app, then that is what it should do. Preventing it will be like stopping a desktop app from closing when a user clicks the close button. It's just confusing and even annoying to regular users. Just MHO.

@Kobzol
Copy link

Kobzol commented Aug 9, 2016

I do agree that it is bad to prevent users from closing the app, but it may have some valid use cases. For example in my app, if I'm at a certain root view and I press the back button, I want to log out instead of closing the app. At least we should be able to react to the event, if not prevent it. It would be great if we could choose a backbutton behaviour when we need to and rely on the default behaviour otherwise (#7590).

@dylanvdmerwe
Copy link
Contributor

dylanvdmerwe commented Aug 16, 2016

As always, my advice is to follow the native paradigms as much as possible even if they do not make UX sense.

@rjv
Copy link

rjv commented Sep 1, 2016

I think when you traverse through tabs it should not contribute to the overall navigation history. In other words, pressing back should not take me to the "previous" tab. Each tab page should essentially be treated as the root.

@jabas06
Copy link

jabas06 commented Sep 26, 2016

Hello @jgw96, I've an issue with the sidemenu and backbutton but not sure whether it is the same issue you're describing here, because your are talking more about the app getting closed by the backbutton.

On Android, when I have the sidemenu open, the backbutton always navigates back through the stack and only closes the app when the stack is empty.

In native apps the backbutton shall close the sidemenu.

@burhanyldz
Copy link

burhanyldz commented Oct 5, 2016

@jabas06 Yeah, that too. I had to use the following until this is fixed.

this.platform.registerBackButtonAction(()=>{
        if(this.menu.isOpen()){
          this.menu.close();
        }else{ ...

},1);

@dylanvdmerwe
Copy link
Contributor

dylanvdmerwe commented Dec 2, 2016

Can we get this issue added into a milestone please? @jgw96 @manucorporat

Note this is still relevant in RC3.

@yannbf
Copy link
Contributor

yannbf commented Dec 2, 2016

+1 to this, especially in regards to tabs history. Sidemenu closing is also a really important fix.

@manucorporat manucorporat self-assigned this Dec 2, 2016
@manucorporat manucorporat added this to the 2.0.0-rc.4 milestone Dec 2, 2016
@jlucfarias
Copy link

@jgw96 you can put the link of the commit that fix these issues?

@manucorporat
Copy link
Contributor

@John-Luke
Sidemenu:
8de253a

Modal:
5567191

@manucorporat
Copy link
Contributor

@jgw96

In a native app with a sidemenu when you navigate to another page that is not the "home" page and then tap the back button it takes you back to the "home" page. Ionic 2 simply closes the app.

This is not something we can fix, but it should be in the developer-side. If the sidemenu setRoot() a different page, then it becomes the root page. Ionic can't make more assumptions here, if they want to navPop() to go back to Home, then they should use nav.Push() instead of nav.setRoot()

manucorporat added a commit that referenced this issue Dec 3, 2016
@graphefruit
Copy link

@manucorporat Sorry to grab into this closed issue.
If you use nav.push you'll get the next window with the back button, instead the menu - icon.
So the point everyone would need to do is to customize it yourself on the normal "root-pages" without having to see the back-button?

Thanks
Graphefruit

@xiaosan666
Copy link

https://github.com/yanxiaojun617/ionic2_tabs
or
http://www.jianshu.com/p/6aa5a8318092

@naveedahmed1
Copy link

Some users have expressed the desire to be able to stop the back button from closing the app in the situation where pressing the back button should close the app. I have mixed feelings about this as its generally considered bad ux to prevent a default operating system action and can seem "spammy" to stop an app from closing.

What if an option is provided to let developer decide if they want to close the app or suspend it when back buttons is pressed? Pressing back button on Facebook and WhatsApp doesnt close the app rather it minimize the app.

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. 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.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests