diff --git a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.h b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.h index b61196c4c57..823ac45486e 100644 --- a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.h +++ b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.h @@ -27,4 +27,9 @@ */ - (void)dismissViewController:(UIViewController *)modalViewController animated:(BOOL)animated; +/** + * Should be called by subclasses when ViewController is dismissed. + */ +- (void)didDismissViewController; + @end diff --git a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index 6e24d39105e..3e3624acbf4 100644 --- a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -7,6 +7,8 @@ #import "RCTModalHostViewComponentView.h" +#import +#import #import #import #import @@ -137,7 +139,16 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( - (void)dismissViewController:(UIViewController *)modalViewController animated:(BOOL)animated { - [modalViewController dismissViewControllerAnimated:animated completion:nil]; + [modalViewController dismissViewControllerAnimated:animated + completion:^{ + [self didDismissViewController]; + }]; +} + +- (void)didDismissViewController +{ + const auto &props = *std::static_pointer_cast(_props); + [[RCTBridge currentBridge].modalManager modalDismissed:@(props.identifier)]; } - (void)ensurePresentedOnlyIfNeeded diff --git a/React/Views/RCTModalManager.h b/React/Views/RCTModalManager.h index 4fbe6dfbd01..a34d801448c 100644 --- a/React/Views/RCTModalManager.h +++ b/React/Views/RCTModalManager.h @@ -7,6 +7,7 @@ #import +#import #import #import @@ -15,3 +16,9 @@ - (void)modalDismissed:(NSNumber *)modalID; @end + +@interface RCTBridge (RCTModalManager) + +@property (nonatomic, readonly) RCTModalManager *modalManager; + +@end diff --git a/React/Views/RCTModalManager.m b/React/Views/RCTModalManager.m index 992b73c62db..399c025a161 100644 --- a/React/Views/RCTModalManager.m +++ b/React/Views/RCTModalManager.m @@ -40,3 +40,12 @@ RCT_EXPORT_MODULE(); } @end + +@implementation RCTBridge (RCTDevSettings) + +- (RCTModalManager *)modalManager +{ + return [self moduleForClass:[RCTModalManager class]]; +} + +@end