Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[router]: ensure navigation events are fired at correct target (#27485)
# Why Expo Router was incorrectly firing events with the incorrect navigator target. This would cause situations where the event was ignored or the state in correct. The result of this was a sublty incorrect routing state that was - causing incorrect back history - navigation state was at the incorrect level in the hierarchy. # How I rewrote `getNavigateAction` to get the action in a single pass. Previously we were getting the action, and then refining the action based up on the parent navigator. This approach could have worked, but the structure of the navigation action is, well, weird. This made converting an action into the targeted action error prone. The new approach is to first identify the target, and then build the correct navigation action. # Test Plan The fixed heirarachy (and incorrect back behaviour) can be demonstrated by [this test](https://github.com/expo/expo/blob/0dd5fd0bea34c5d8faeb6b4ada8ea82cfe220c39/packages/expo-router/src/__tests__/push.test.ios.tsx#L12). Now the routes are correctly pushing to the `<Stack />` inside the `(group)` This incorrect back behaviour can be demonstrated by [this test](https://github.com/expo/expo/blob/0dd5fd0bea34c5d8faeb6b4ada8ea82cfe220c39/packages/expo-router/src/__tests__/stacks.test.ios.tsx#L98). Notice how some routes were previously not added to the history, causing the back behaviour to "skip" a route # Checklist <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
- Loading branch information