feat(iOS, FormSheet v5): Introduce PresentationManager for FormSheet component#4086
Open
t0maboro wants to merge 8 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Introduces a dedicated iOS RNSFormSheetPresentationManager (with a 4-phase state machine) to prevent FormSheet presentation/dismissal calls from desynchronizing when isOpen toggles rapidly during UIKit animations.
Changes:
- Added
RNSFormSheetPresentationStateenum andRNSFormSheetPresentationManagerto serialize/suppress conflicting transitions and re-evaluate desired state on animation completion. - Refactored
RNSFormSheetContentControllerto delegate presentation logic to the manager and to force a full configuration refresh insideprepareForPresentation. - Added a new Single Feature Test scenario that stress-toggles
isOpen, and registered it in the FormSheet scenario group.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ios/gamma/modals/form-sheet/RNSFormSheetPresentationState.h | New enum defining the manager’s presentation phases. |
| ios/gamma/modals/form-sheet/RNSFormSheetPresentationManager.h | New manager interface for driving presentation transitions. |
| ios/gamma/modals/form-sheet/RNSFormSheetPresentationManager.mm | Manager implementation with guarded present/dismiss and completion re-evaluation. |
| ios/gamma/modals/form-sheet/RNSFormSheetContentController.h | Exposes prepareForPresentation for the manager. |
| ios/gamma/modals/form-sheet/RNSFormSheetContentController.mm | Removes primitive presentation logic; forces configuration refresh during presentation prep; forwards native dismiss to manager. |
| apps/src/tests/single-feature-tests/form-sheet/test-form-sheet-presentation-state-ios/scenario.md | Manual SFT steps for rapid open/close toggling and native dismiss verification. |
| apps/src/tests/single-feature-tests/form-sheet/test-form-sheet-presentation-state-ios/scenario-description.ts | Registers metadata for the new SFT. |
| apps/src/tests/single-feature-tests/form-sheet/test-form-sheet-presentation-state-ios/index.tsx | Implements the rapid toggle UI for the new SFT. |
| apps/src/tests/single-feature-tests/form-sheet/index.ts | Adds the new SFT to the FormSheet scenario group. |
Comments suppressed due to low confidence (1)
ios/gamma/modals/form-sheet/RNSFormSheetContentController.mm:10
RNSPresentationSourceProvider.handRCTLog.hare no longer referenced in this file after moving presentation logic toRNSFormSheetPresentationManager. Consider removing these imports to avoid unnecessary dependencies and reduce compile overhead.
#import "RNSFormSheetContentController.h"
#import "RNSFormSheetConfigurationApplicator.h"
#import "RNSFormSheetContentView.h"
#import "RNSFormSheetPresentationManager.h"
#import "RNSFormSheetUpdateCoordinator.h"
#import "RNSFormSheetUpdateFlags.h"
#import "RNSPresentationSourceProvider.h"
#import <React/RCTAssert.h>
#import <React/RCTLog.h>
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR addresses cases where rapid updates to the
isOpenprop from JS may cause the native presentation state to desynchronize. Previously, the presentation logic was primitive, and triggering a present or dismiss while another UIKit animation was already in flight would cause UIKit to ignore the call, permanently breaking the component's state.I'm solving this by introducing a dedicated PresentationManager with a state machine.
Dismissed, and will only fire a dismiss if the state isPresented.isOpenprop while an animation (statePresentingorDismissing) is actively running, the manager intentionally suppresses the call to prevent conflicts.DismissingtoDismissed, fromPresentingtoPresented) and then immediately re-evaluates the desired React state. If React updates the value mid-animation, the manager instantly catches up and triggers the next transition.Note:
The quick
isOpentoggle may try to apply the configuration to an oldsheetPresentationControllerthat we're going to destroy inDismissing -> Dismissedtransition. I need to force a complete configuration refresh insideprepareForPresentationto guarantee the newly recreated UIKit controller always receives the latest props before it appears on screen.Closes: https://github.com/software-mansion/react-native-screens-labs/issues/1420
Changes
RNSFormSheetPresentationStatewas definedRNSFormSheetPresentationManagerwas defined to define the state machineRNSFormSheetContentControllerBefore & after - visual documentation
before.mov
after.mov
Test plan
Added a new dedicated SFT that will toggle
isOpenprop twice with timeout 32ms.Checklist