mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Calling Paper TextInput setTextAndSelection view command now dirties layout
Summary: Changelog: [Internal] Previously `setTextAndSelection` was not dirtying layout. This would cause an issue where `setTextAndSelection` causes layout change. For example calling setTextAndSelection with empty string on a multiline auto expanding text input. I changed one example in TextInputSharedExamples.js, "Live Re-Write (no spaces allowed) and clear" example is now multiline. This allows to test whether `setTextAndSelection` dirties layout. Enter multiline string to to the example text input and press clear. Observe that the text input shrinks to single line height. Reviewed By: shergin Differential Revision: D21182990 fbshipit-source-id: de8501ea0b97012cf4cdf8d5f658649139f92da6
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e3e900805b
commit
e68f9bf768
@@ -125,8 +125,18 @@ RCT_EXPORT_METHOD(setTextAndSelection : (nonnull NSNumber *)viewTag
|
||||
{
|
||||
[self.bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary<NSNumber *, UIView *> *viewRegistry) {
|
||||
RCTBaseTextInputView *view = (RCTBaseTextInputView *)viewRegistry[viewTag];
|
||||
view.mostRecentEventCount = mostRecentEventCount;
|
||||
[view setText:value selectionStart:start selectionEnd:end];
|
||||
NSInteger eventLag = view.nativeEventCount - mostRecentEventCount;
|
||||
if (eventLag != 0) {
|
||||
return;
|
||||
}
|
||||
RCTExecuteOnUIManagerQueue(^{
|
||||
RCTBaseTextInputShadowView *shadowView = (RCTBaseTextInputShadowView *)[self.bridge.uiManager shadowViewForReactTag:viewTag];
|
||||
[shadowView setText:value];
|
||||
[self.bridge.uiManager setNeedsLayout];
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[view setSelectionStart:start selectionEnd:end];
|
||||
});
|
||||
});
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user