Skip to content

Commit

Permalink
Call handleUpdateLayout even if the content didn't change
Browse files Browse the repository at this point in the history
Summary:
This PR fixes #11096.

I don't know enough the ReactAndroid's source code so I don't know if this is correct but I hope it is.

In a recent commit (d4b8ae7), the `dispatchUpdates` method now returns a boolean to dispatch or not the `onLayout` event. This works well but if the content is unchanged, the line `nativeViewHierarchyOptimizer.handleUpdateLayout(this);` is never called. I don't know if it was intended but it was this which introduces my issue. I called this again even if the content didn't change. This was the behaviour before 0.38 so I guess I didn't break anything.

**Test plan (required)**

I tested my pretty big app with this fix and every screen is ok.
Closes #11222

Differential Revision: D4252101

Pulled By: astreet

fbshipit-source-id: 551559234631ac37245a854d81ba568f0ddb02dd
  • Loading branch information
Yann Pringault authored and Martin Konicek committed Dec 5, 2016
1 parent fd2313f commit 9a13def
Showing 1 changed file with 4 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -250,23 +250,10 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) {
}

if (hasNewLayout()) {
float newLeft = Math.round(absoluteX + getLayoutX());
float newTop = Math.round(absoluteY + getLayoutY());
float newRight = Math.round(absoluteX + getLayoutX() + getLayoutWidth());
float newBottom = Math.round(absoluteY + getLayoutY() + getLayoutHeight());

if (newLeft == mAbsoluteLeft &&
newRight == mAbsoluteRight &&
newTop == mAbsoluteTop &&
newBottom == mAbsoluteBottom) {
return false;
}

mAbsoluteLeft = newLeft;
mAbsoluteTop = newTop;
mAbsoluteRight = newRight;
mAbsoluteBottom = newBottom;

mAbsoluteLeft = Math.round(absoluteX + getLayoutX());
mAbsoluteTop = Math.round(absoluteY + getLayoutY());
mAbsoluteRight = Math.round(absoluteX + getLayoutX() + getLayoutWidth());
mAbsoluteBottom = Math.round(absoluteY + getLayoutY() + getLayoutHeight());
nativeViewHierarchyOptimizer.handleUpdateLayout(this);
return true;
} else {
Expand Down

1 comment on commit 9a13def

@mschipperheyn
Copy link

Choose a reason for hiding this comment

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

Hi, I think there may be an issue with this commit. Please have a look at this problem description:

#11441

Please sign in to comment.