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
This commit is contained in:
Mehdi Mulani 2017-09-25 10:56:16 -07:00 committed by Facebook Github Bot
parent d005c8c08a
commit e220878b00
2 changed files with 7 additions and 2 deletions

View File

@ -784,11 +784,10 @@ RCT_EXPORT_METHOD(removeSubviewsFromContainerWithID:(nonnull NSNumber *)containe
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.property;
[deletingLayoutAnimation performAnimations:^{

View File

@ -160,6 +160,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:coder)
{
[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]) {
return;
}
if (!_isPresented && self.window) {
RCTAssert(self.reactViewController, @"Can't present modal view controller without a presenting view controller");