Browse files

Add a hack to fix the Modal component interacting with LayoutAnimation

Summary: As per the comment, <Modal> uses entering/leaving the view hierarchy as a cue to show/hide the modal. By re-adding it, we are causing a bunch of confusion.

Reviewed By: shergin

Differential Revision: D5893607

fbshipit-source-id: ecd05799751a9bba843998ae93f24fe35edca8b4
  • Loading branch information...
mmmulani authored and facebook-github-bot committed Sep 25, 2017
1 parent d005c8c commit e220878b00c1cfc34fdd3d232626d31ee72057ff
Showing with 7 additions and 2 deletions.
  1. +1 −2 React/Modules/RCTUIManager.m
  2. +6 −0 React/Views/RCTModalHostView.m
@@ -784,11 +784,10 @@ - (void)_removeChildren:(NSArray<UIView *> *)children
UIView *originalSuperview = removedChild.superview;
NSUInteger originalIndex = [originalSuperview.subviews indexOfObjectIdenticalTo:removedChild];
[container removeReactSubview:removedChild];
[originalSuperview insertSubview:removedChild atIndex:originalIndex];
// Disable user interaction while the view is animating
// since the view is (conseptually) deleted and not supposed to be interactive.
removedChild.userInteractionEnabled = NO;
[originalSuperview insertSubview:removedChild atIndex:originalIndex];
NSString *property =;
[deletingLayoutAnimation performAnimations:^{
@@ -160,6 +160,12 @@ - (void)didMoveToWindow
[super didMoveToWindow];
// In the case where there is a LayoutAnimation, we will be reinserted into the view hierarchy but only for aesthetic purposes.
// In such a case, we should NOT represent the <Modal>.
if (!self.userInteractionEnabled && ![self.superview.reactSubviews containsObject:self]) {
if (!_isPresented && self.window) {
RCTAssert(self.reactViewController, @"Can't present modal view controller without a presenting view controller");

0 comments on commit e220878

Please sign in to comment.