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

Android hardware back button unexpected behavior while using drawer when app coming to foreground from background. #2873

Closed
rohitgoyal opened this issue Feb 10, 2018 · 5 comments

Comments

@rohitgoyal
Copy link

Version

  • react-native-router-flux 4.0.0-beta.27
  • react-native 0.51.0

Expected behaviour

Let's say i have screen_1 button on drawer and by clicking it I am going to screen_1. Now press the home button(App goes to background) and open the app again(App comes to foreground). Now when i press the android back button the app should go back to drawer screen (drawer in open state) and again pressing the back button should close the drawer.

Actual behaviour

I have screen_1 button on drawer and by clicking it I am going to screen_1. Now press the home button(App goes to background) and open the app again(App comes to foreground). Now when i press the android back button the app goes back to home screen (drawer in close state) and again pressing the back button open the screen_1 screen.

Steps to reproduce

render(){
  return <Router>
      <Scene key="root" headerMode={'screen'}
      >
        <Scene key="drawer" drawer
          contentComponent={SideMenu}
          drawerOpenRoute= 'DrawerOpen'
          drawerCloseRoute= 'DrawerClose'
          drawerToggleRoute= 'DrawerToggle'
          initial={true}
          hideNavBar={true}
          // drawerWidth={400}
        >
          <Scene key="home" component={Home}/>
        </Scene>
        <Scene key="screen_1" component={Screen_1}  />
    </Scene>
  </Router>
}

Just have these routes. Have anything in Home, Screen_1 and SideMenu.

@rohitgoyal
Copy link
Author

@aksonov Have any idea about this?

@aksonov
Copy link
Owner

aksonov commented Aug 8, 2018

Please try to reproduce it with Example project and latest version 4.0.0-beta.40. Feel free to open if the issue still exists

If it is still actual, please ask @daviscabral because he works with Android

@aksonov aksonov closed this as completed Aug 8, 2018
@andidev
Copy link

andidev commented Dec 6, 2018

@daviscabral @aksonov
Could you reopen this? This is still there in latest release 4.0.6. I have been having this bug a long time know not able to figure out what was triggering it.

I also found out another situation when this bug occurs.

  1. Open app
  2. Click on a InputText that the keyboard displays
  3. Open drawer
  4. Open new scene from drawer
  5. Close scene with hardware back button
    (note that this closes both the scene and the drawer, though the scene component never get unmounted, i.e. componentWillUnmount is never called)
  6. Open the drawer again
  7. Try to open a scene from the drawer and it is now not possible

This may be related to
facebook/react-native#21316

I would love to assist further. I could create an example project If needed or test a fix.

@andidev
Copy link

andidev commented Dec 7, 2018

Okey I just migrated a part of my code to React Navigation and it looks like this issue is there as well (in both rohitgoyal case and my case). One difference though. When closing the scene from drawer (step 4), the opened modal is still visible (so that would somewhat explain that componentWillUnmount is never called).

So I guess this is a React Navigation bug.

@MeetTheBest
Copy link

@rohitgoyal Hi Guy, Have you solved the problem.I had the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants