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

iOS Modal dismiss causes strange navigation stack pop #2668

Closed
Jpoliachik opened this issue Feb 4, 2025 · 8 comments · Fixed by #2671
Closed

iOS Modal dismiss causes strange navigation stack pop #2668

Jpoliachik opened this issue Feb 4, 2025 · 8 comments · Fixed by #2671
Labels
Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided

Comments

@Jpoliachik
Copy link

Jpoliachik commented Feb 4, 2025

Description

Showing a Modal, then updating state to set visible: false at the same time as we use expo-router to navigate to a new screen, we see a slight pause and noticeable glitch, then the screen where the modal was shown gets popped off the navigation stack when it should not.

See app/child/index.tsx in the repro:

setModalVisible(false);
router.navigate("/child/secondchild");

Which causes this issue:

ios-modalbug.mov

This only happens on iOS, and it only happens when dismissing a Modal at the same time as navigating to a new route.

The only workaround I found for now is to use FullWindowOverlay on iOS instead of Modal.

Steps to reproduce

Minimal repro from a fresh create-expo-app can be found here, with a video showing the issue:

https://github.com/Jpoliachik/RNModalNavigateBug

Snack or a link to a repository

https://github.com/Jpoliachik/RNModalNavigateBug

Screens version

4.4.0

React Native version

0.76.6

Platforms

iOS

JavaScript runtime

None

Workflow

Expo managed workflow

Architecture

None

Build type

None

Device

iOS simulator

Device model

No response

Acknowledgements

Yes

@github-actions github-actions bot added Repro provided A reproduction with a snack or repo is provided Platform: iOS This issue is specific to iOS labels Feb 4, 2025
@Jpoliachik Jpoliachik changed the title iOS Modal dismiss causes navigation stack to pop iOS Modal dismiss causes strange navigation stack pop Feb 4, 2025
@kkafar
Copy link
Member

kkafar commented Feb 5, 2025

@Jpoliachik I'll into it, but much simpler workaround be most likely just to delay the navigation call by a frame, e.g. by using it in setTimeout or something.

@kkafar
Copy link
Member

kkafar commented Feb 5, 2025

I confirm that the issue is reproducible.

@kkafar
Copy link
Member

kkafar commented Feb 6, 2025

Should be fixed with #2671

I'll release another beta by the end of the Friday

@Jpoliachik
Copy link
Author

Thanks @kkafar!

@kkafar
Copy link
Member

kkafar commented Feb 7, 2025

4.7.0-beta.3 is on npm fyi

@RohovDmytro
Copy link

RohovDmytro commented Feb 9, 2025

@kkafar The beta.3 still causes an issue for me. Here a quick video from Android:

video_2025-02-09_17-17-52.mp4

The video does not highlight a gesture animation, so to be clear I was applying a gesture swipe from left edge of the screen all the time. At first, only a single screen was dismissed (that's what expected). Last time the swipe caused both screen to be dismissed.

It seems like the one of the screens was dismissed due to touch on a backdrop and the second one due to a swipe gesture.

Also, might be worth pointing out that the presentation mode for the screen stack is formSheet.

@RohovDmytro
Copy link

I think what happens is that if the swipe back gesture starts on a backdrop, that triggers closing of a modal, and then the swipe back gesture happens which closes the second modal.

I can see a solution to close a modal not upon onPressIn (what happens now). Closing the modal during onPressOut will leave space to cancel navigation action if it would be already handled by back gesture / view gets unmounted.

@kkafar
Copy link
Member

kkafar commented Feb 10, 2025

@RohovDmytro the original issue is iOS specific and I consider it solved. The issue you describe seems to relate to different platform and different behaviour. Please open separate issue & describe the problem there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform: iOS This issue is specific to iOS Repro provided A reproduction with a snack or repo is provided
Projects
None yet
3 participants