[v5] Fix Bottom Sheet Closing on Orientation Change When Modal Exceeds Container Bounds #2156
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theuseBottomSheetDynamicSnapPoints[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