Skip to content

Commit 7c2a425

Browse files
authored
refactor(iOS, Fabric): move updateFormSheetPresentationStyle to updateProps (#2952)
## Description Previously, `updateFormSheetPresentationStyle` was called from `finalizeUpdates` every time it was called, which would run many times when the sheet was being dragged. This impacted performance and was the cause of the bug which was fixed in #2935 by introducing a flag for setting initial detent. Now, we are checking `updateMask` in `finalizeUpdates` method. If the props have changed, we call `updateFormSheetPresentationStyle`. We don't need the flag anymore so I removed it as well. Thanks to @lodev09 for [reporting the problem and suggesting possible solution](#2935 (comment)). ## Changes - remove `_sheetHasInitialDetentSet` - check if props have changed using `updateMask` before calling `updateFormSheetPresentationStyle` ## Test code and steps to reproduce Run formSheet-related test screens in the example app, such as `Test2543`, `TestFormSheet` (you can change `sheetInitialDetent` in the file and save to see the update), `Test2877`. ## Checklist - [x] Included code example that can be used to test this change - [ ] Ensured that CI passes
1 parent 033152c commit 7c2a425

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

ios/RNSScreen.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ - (void)sheetPresentationControllerDidChangeSelectedDetentIdentifier:
966966
* Updates settings for sheet presentation controller.
967967
* Note that this method should not be called inside `stackPresentation` setter, because on Paper we don't have
968968
* guarantee that values of all related props had been updated earlier. It should be invoked from `didSetProps`.
969-
* On Fabric we have control over prop-setting process but it might be reasonable to run it from `finalizeUpdates`.
969+
* On Fabric we run it from `finalizeUpdates` if props have changed.
970970
*/
971971
- (void)updateFormSheetPresentationStyle
972972
{
@@ -1335,8 +1335,10 @@ - (void)finalizeUpdates:(RNComponentViewUpdateMask)updateMask
13351335
{
13361336
[super finalizeUpdates:updateMask];
13371337
#if !TARGET_OS_TV && !TARGET_OS_VISION
1338-
[self updateFormSheetPresentationStyle];
1339-
#endif // !TARGET_OS_TV
1338+
if (updateMask & RNComponentViewUpdateMaskProps) {
1339+
[self updateFormSheetPresentationStyle];
1340+
}
1341+
#endif // !TARGET_OS_TV && !TARGET_OS_VISION
13401342
}
13411343

13421344
#pragma mark - Paper specific

0 commit comments

Comments
 (0)