Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Bug: Set a React Controller whose view is a RCTRootView as a part… #16893

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions React/Base/RCTRootContentView.m
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,14 @@ - (void)updateAvailableSize
return;
}

//unnecessary to update avaliableSize, it's triggered by setBounds: from RCTUIManager
if (self.superview) {
CGRect superviewFrame = self.superview.bounds;
if (!CGRectEqualToRect(superviewFrame, self.frame)) {
Copy link
Contributor

@shergin shergin Nov 21, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, but what is an idea/reasoning behind this changeset?
Comparing view.frame with superview.bounds makes no any sense, I am afraid.

Copy link
Author

@fishmwei fishmwei Nov 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shergin
I always think that the size of content view should be equal to its super view's size. That's why you set content's frame in the function layoutSubviews of rootView ?

- (void)layoutSubviews
{
  [super layoutSubviews];
  _contentView.frame = self.bounds;  // here
  _loadingView.center = (CGPoint){
    CGRectGetMidX(self.bounds),
    CGRectGetMidY(self.bounds)
  };
}

if view.frame != superview.bounds, it's invalidate. If update avaliableSize in the case, it will lead to set view.bounds with a size which does not equal to superview.bounds later, so the bug occurs.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shergin what's your opinion?

return;
}
}

[_bridge.uiManager setAvailableSize:self.availableSize forRootView:self];
}

Expand Down