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

v7 Navigating back randomly causes NAVIGATE action to be dispatched instead of GO_BACK #11897

Closed
3 of 11 tasks
Caundy opened this issue Mar 16, 2024 · 3 comments
Closed
3 of 11 tasks

Comments

@Caundy
Copy link

Caundy commented Mar 16, 2024

Current behavior

Very rarely and seemingly randomly, when using props.navigation.goBack(), the GO_BACK action is replaced by NAVIGATE one.

Using dynamic configuration with @react-navigation v7 + backBehavior: ‘history’.

Navigation structure is as follow:

BOTTOM-TABS
    NATIVE_STACK A
        LIST_SCREEN + DETAILS_SCREEN
    NATIVE_STACK B
        LIST_SCREEN + DETAILS_SCREEN
    NATIVE_STACK C
        LIST_SCREEN + DETAILS_SCREEN
    NATIVE_STACK D
        LIST_SCREEN + DETAILS_SCREEN

When following actions’ order like so:

1 Load app, get navigated to NATIVE_STACK A (LIST_SCREEN)
2 Using bottom tab, navigate to NATIVE_STACK C  (LIST_SCREEN)
3 Open the DETAILS_SCREEN for one of the items

4 Press hardware back button or icon triggering props.navigation.goBack()
5 Observe navigation correctly going back to NATIVE_STACK C’s LIST_SCREEN

6 Repeat steps 3&4 (open details -> go back) until the bug occurs
7 Observe navigation having been set to NATIVE_STACK D’s LIST_SCREEN

After the error occurs, when navigating to the NATIVE_STACK C using bottom tab, one can observe the DETAILS_SCREEN has not been removed.
Additionally, listener added to the beforeRemove event does not trigger when trying to goBack when the error occurs.

The issue happens in all the stacks where user tries to trigger the back navigation - can happen in NATIVE_STACKs A,B or C. When the bug occurs, the user is always navigated to the last stack in the bottom tab navigator.

Expected behavior

props.navigation.goBack should always result in navigating back, rather than randomly navigating to another stack within the bottom tab navigator

Reproduction

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

"@react-navigation/bottom-tabs": "^7.0.0-alpha.8",
"@react-navigation/devtools": "^6.0.25",
"@react-navigation/native": "^7.0.0-alpha.7",
"@react-navigation/native-stack": "^7.0.0-alpha.12",
"react-native": "0.73.6",

@Caundy Caundy added the bug label Mar 16, 2024
Copy link

Hey @Caundy! Thanks for opening the issue. It seems that the issue doesn't contain a link to a repro.

The best way to get attention to your issue is to provide an easy way for a developer to reproduce the issue.

You can provide a repro using any of the following:

A snack link is preferred since it's the easiest way to both create and share a repro. If it's not possible to create a repro using a snack, link to a GitHub repo under your username is a good alternative. Don't link to a branch or specific file etc. as it won't be detected.

Try to keep the repro as small as possible by narrowing down the minimal amount of code needed to reproduce the issue. Don't link to your entire project or a project containing code unrelated to the issue. See "How to create a Minimal, Reproducible Example" for more information.

You can edit your original issue to include a link to the repro, or leave it as a comment. The issue will be closed automatically after a while if you don't provide a repro.

Copy link

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • @react-navigation/bottom-tabs (found: 7.0.0-alpha.8, latest: 6.5.19)
  • @react-navigation/native (found: 7.0.0-alpha.7, latest: 6.1.16)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

Copy link

Hello 👋, this issue has been open for more than a month without a repro or any activity. If the issue is still present in the latest version, please provide a repro or leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution or workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix it.

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