-
-
Notifications
You must be signed in to change notification settings - Fork 576
feat(iOS): make fitToContents
sheet height react to dynamic content
#2877
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
feat(iOS): make fitToContents
sheet height react to dynamic content
#2877
Conversation
In the future, it might be necessary to investigate the issue in more detail: why updating detents causes the glitches to appear and why new frames have same height but different width on an iPad (it sometimes alternates between 2 values, e.g. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great.
I will want to put some time into debugging here, so that we understand the changes 😅
I'll try to find some time next week.
This might not be related but I found a bug while working on new features for the If you move the prop update to |
@lodev09 thanks! Do you have any more specific information, e.g. when this issue is triggered? How can we observe the visual glitches? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks solid. I've debugged it for few minutes now & seems that all frame updates are sensible & for a known reason.
I've allowed myself to improve example & do a small variable renaming.
@kkafar my fork has some added features like the react-native-screens/ios/RNSScreen.mm Lines 1326 to 1332 in d1e9aaf
Every time the sheet is dragged, this block is being called. I have a fix for it in my fork, together with some other features. https://github.com/lodev09/react-native-screens For the context, had to implement these changes due to requirement for our app. Feel free to check it out in the meantime when you get the chance. Simulator.Screen.Recording.-.iPhone.16.Pro.Max.-.2025-04-26.at.05.42.34.mp4 |
Created draft PR here: |
Description
Allows
fitToContents
sheet's height to adapt to dynamic content on iOS.contentWrapper:(RNSScreenContentWrapper *)contentWrapper receivedReactFrame:(CGRect)reactFrame
receives many frames, some of them contain the same dimensions. Calling[self setAllowedDetentsForSheet:sheetController to:detents animate:YES]
mutliple times, even with the samedetents
, causes visual glitches (dimming behing formSheet on iPhone/iPad and header on iPad have very odd-looking animations).Before, we would set
_didSetSheetAllowedDetentsOnController
toYES
after setting detents for the first time and then ignore all incoming frames - including those with new height after content changed its height. Now, we remember frame height we received, and when we receive a new frame, we compare new height to the previous value. If it is different, we update detents usingsetAllowedDetentsForSheet
.Supersedes #2741.
Fixes #2688.
Changes
_didSetSheetAllowedDetentsOnController
with float_sheetFrameHeight
Test2877
test screenScreenshots / GIFs
2877_before.mp4
2877_after.mp4
Test code and steps to reproduce
Enter
Test2877
screen and open form sheet. Its height should adapt to displayed content every second.Checklist