Fix a bug with comment box positioning.

Summary: We do want to only apply updates when a view previously wasn't mounted and didn't have a backing view created.  Previously we were applying updates to the view regardless of the mount state, which resulted in positioning bugs.  Rather than revert, I cleaned up the code Ahmed fixed, since didUpdate || ensureBackingViewIsCreated() was both a bug and obscure, as the two should have a swapped order.

Reviewed By: sriramramani

Differential Revision: D3538734
This commit is contained in:
Seth Kirby 2016-07-08 18:27:46 -07:00 committed by Ahmed El-Helw
parent 7562f9d6f5
commit e674185ea1
2 changed files with 14 additions and 5 deletions

View File

@ -224,10 +224,14 @@ public class FlatUIImplementation extends UIImplementation {
callback);
}
private void ensureMountsToViewAndBackingViewIsCreated(int reactTag) {
private boolean ensureMountsToViewAndBackingViewIsCreated(int reactTag) {
FlatShadowNode node = (FlatShadowNode) resolveShadowNode(reactTag);
if (node.isBackingViewCreated()) {
return false;
}
node.forceMountToView();
mStateBuilder.ensureBackingViewIsCreated(node);
return true;
}
@Override
@ -249,8 +253,15 @@ public class FlatUIImplementation extends UIImplementation {
@Override
public void dispatchViewManagerCommand(int reactTag, int commandId, ReadableArray commandArgs) {
ensureMountsToViewAndBackingViewIsCreated(reactTag);
mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag));
if (ensureMountsToViewAndBackingViewIsCreated(reactTag)) {
// need to make sure any ui operations (UpdateViewGroup, for example, etc) have already
// happened before we actually dispatch the view manager command (since otherwise, the command
// may go to an empty shell parent without its children, which is against the specs). note
// that we only want to applyUpdates if the view has not yet been created so that it does
// get created (otherwise, we may end up changing the View's position when we're not supposed
// to, for example).
mStateBuilder.applyUpdates((FlatShadowNode) resolveShadowNode(reactTag));
}
super.dispatchViewManagerCommand(reactTag, commandId, commandArgs);
}

View File

@ -164,8 +164,6 @@ import com.facebook.react.views.view.ReactClippingViewGroupHelper;
@Override
public void dispatchDraw(Canvas canvas) {
super.dispatchDraw(canvas);
if (mRemoveClippedSubviews) {
for (DrawCommand drawCommand : mDrawCommands) {
if (drawCommand instanceof DrawView) {