Skip to content

Commit ed2300e

Browse files
committed
fix: set _prevSize before making yoga node dirty
1 parent 107c90f commit ed2300e

1 file changed

Lines changed: 12 additions & 16 deletions

File tree

ios/internals/EnrichedTextInputViewShadowNode.mm

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,9 @@
1515
const auto nextSize = state.getContentSize();
1616

1717
if (_prevContentSize != nextSize) {
18+
_prevContentSize = nextSize;
1819
YGNodeMarkDirty(&yogaNode_);
1920
}
20-
21-
_prevContentSize = nextSize;
2221
}
2322

2423
id EnrichedTextInputViewShadowNode::setupMockTextInputView_() const {
@@ -74,26 +73,23 @@
7473
_prevContentSize = size;
7574
return constraints.clamp(size);
7675
}
76+
}
77+
__block CGSize estimatedSize;
78+
// synchronously dispatch to main thread if needed
79+
if ([NSThread isMainThread]) {
80+
EnrichedTextInputView *mockTextInputView = setupMockTextInputView_();
81+
estimatedSize = [mockTextInputView
82+
measureInitialSizeWithMaxWidth:constraints.maximumSize.width];
7783
} else {
78-
__block CGSize estimatedSize;
79-
// synchronously dispatch to main thread if needed
80-
if ([NSThread isMainThread]) {
84+
dispatch_sync(dispatch_get_main_queue(), ^{
8185
EnrichedTextInputView *mockTextInputView = setupMockTextInputView_();
8286
estimatedSize = [mockTextInputView
8387
measureInitialSizeWithMaxWidth:constraints.maximumSize.width];
84-
} else {
85-
dispatch_sync(dispatch_get_main_queue(), ^{
86-
EnrichedTextInputView *mockTextInputView = setupMockTextInputView_();
87-
estimatedSize = [mockTextInputView
88-
measureInitialSizeWithMaxWidth:constraints.maximumSize.width];
89-
});
90-
}
91-
92-
return {estimatedSize.width,
93-
MIN(estimatedSize.height, constraints.maximumSize.height)};
88+
});
9489
}
9590

96-
return Size();
91+
return {estimatedSize.width,
92+
MIN(estimatedSize.height, constraints.maximumSize.height)};
9793
}
9894

9995
} // namespace facebook::react

0 commit comments

Comments
 (0)