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

[v5] Fix Bottom Sheet Closing on Orientation Change When Modal Exceeds Container Bounds #2156

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

coffe0wl
Copy link

@coffe0wl coffe0wl commented Feb 9, 2025

Motivation:

This PR addresses an issue where the bottom sheet unexpectedly closes when the device orientation changes. The bug occurs when, during an orientation change, the modal's content size exceeds the bottom boundary of its container while the animation is in progress.

The root cause is that the closing logic gets triggered when the modal is detected as being out of bounds, even though no user interaction occurred. This fix ensures that the modal only closes if a user-initiated gesture is detected, preventing unintended dismissals caused by layout recalculations during orientation changes.

This issue specifically occurs when using Dynamic Sizing[v5] or the useBottomSheetDynamicSnapPoints[v4] hook.

Please review the attached videos below:

Not fixed - modal with small content - issue appears
https://github.com/user-attachments/assets/460db1b6-024b-42e3-9d7d-9a63a0d7cf66

Not fixed - modal with big content - no issue
https://github.com/user-attachments/assets/0b8f9653-f6e3-4de3-ae0e-ba28aa1334d0

Fixed - modal with small content - no issue
https://github.com/user-attachments/assets/1c8b5f8f-0625-457e-ac94-b279f14e9b55

Fixed - modal with small content - no issue
https://github.com/user-attachments/assets/c81ed1b4-3c6a-4344-ad61-7c20102b6f0c

@gorhom
Copy link
Owner

gorhom commented Feb 9, 2025

hi @coffe0wl, could you please share a reproducible sample code for the issue

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

Successfully merging this pull request may close these issues.

2 participants