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

Navigating to the Home page after using back browser feature navigates outside the application #11832

Closed
5 of 12 tasks
SlickDomique opened this issue Feb 18, 2024 · 2 comments
Closed
5 of 12 tasks

Comments

@SlickDomique
Copy link
Contributor

Current behavior

While navigating the application and using the browser feature to go back the application will navigate to a completely previous page when trying to go home (/). This happens only after you go to the page in a tab that had some previous page opened.

To replicate the issue in my example open the app and do:

  1. Open new tab and go to any page. After that manually put the app address to the address bar and navigate to it.
  2. Navigate with menu to PageA
  3. Navigate with menu to PageB
  4. Use browser go back (can be button, keyboard shortcut or mouse button)
  5. Navigate with menu to PageB again
  6. Try navigating Home with menu
  7. You will get redirected to a previous page from step 0

Video showcasing the bug https://www.youtube.com/watch?v=tMXZSsK7_28

Expected behavior

Going to / after navigating the page and using back browser feature should open the home page instead of navigating entirely to the previous page.

Reproduction

https://github.com/SlickDomique/navigation-history-bug-react-navigation6

Platform

  • Android
  • iOS
  • Web
  • Windows
  • MacOS

Packages

  • @react-navigation/bottom-tabs
  • @react-navigation/drawer
  • @react-navigation/material-top-tabs
  • @react-navigation/stack
  • @react-navigation/native-stack
  • react-native-tab-view

Environment

  • I've removed the packages that I don't use
package version
@react-navigation/native ^6.1.10
@react-navigation/native-stack ^6.9.18
react-native-safe-area-context 4.8.2
react-native-screens ~3.29.0
react-native-web ~0.19.6
react-native 0.73.4
expo ~50.0.7
node v20.11.1
npm 10.2.4
yarn 1.22.19
osdnk pushed a commit that referenced this issue Feb 23, 2024
…11833)

**Motivation**

Fix for #11832

Before going to negative history index check if the history will return
anything for that index. If that's not the case the previous behavior
would open previously opened page from that tab.

**Test plan**

From my testing project you can test it by

To replicate the issue in my example open the app and do:

1. Open new tab and go to any page. After that manually put the app
address to the address bar and navigate to it.
    2. Navigate with menu to PageA
    3. Navigate with menu to PageB
4. Use browser go back (can be button, keyboard shortcut or mouse
button)
    5. Navigate with menu to PageB again
    6. Try navigating Home with menu
7. You will no longer get redirected to a previous page from step 0 but
to the home page instead
osdnk pushed a commit that referenced this issue Feb 23, 2024
…11833)

**Motivation**

Fix for #11832

Before going to negative history index check if the history will return
anything for that index. If that's not the case the previous behavior
would open previously opened page from that tab.

**Test plan**

From my testing project you can test it by

To replicate the issue in my example open the app and do:

1. Open new tab and go to any page. After that manually put the app
address to the address bar and navigate to it.
    2. Navigate with menu to PageA
    3. Navigate with menu to PageB
4. Use browser go back (can be button, keyboard shortcut or mouse
button)
    5. Navigate with menu to PageB again
    6. Try navigating Home with menu
7. You will no longer get redirected to a previous page from step 0 but
to the home page instead
@SlickDomique
Copy link
Contributor Author

Issue can no longer be replicated in the example repo after updating to the latest version

Copy link

github-actions bot commented Mar 1, 2024

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

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

No branches or pull requests

1 participant