mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Native changes for TextInput.setSelection method
Summary: Native changes in preparation for adding a `setSelection` imperative method to `TextInput`. Changelog: [Internal] Reviewed By: JoshuaGross Differential Revision: D31590771 fbshipit-source-id: eed40d1c2803fec713f2008ab8053a2812249715
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2ae06df58f
commit
f249d21da0
@@ -132,7 +132,9 @@ RCT_EXPORT_METHOD(setTextAndSelection : (nonnull NSNumber *)viewTag
|
||||
}
|
||||
RCTExecuteOnUIManagerQueue(^{
|
||||
RCTBaseTextInputShadowView *shadowView = (RCTBaseTextInputShadowView *)[self.bridge.uiManager shadowViewForReactTag:viewTag];
|
||||
[shadowView setText:value];
|
||||
if (value) {
|
||||
[shadowView setText:value];
|
||||
}
|
||||
[self.bridge.uiManager setNeedsLayout];
|
||||
RCTExecuteOnMainQueue(^{
|
||||
[view setSelectionStart:start selectionEnd:end];
|
||||
|
||||
@@ -420,7 +420,7 @@ using namespace facebook::react;
|
||||
return;
|
||||
}
|
||||
_comingFromJS = YES;
|
||||
if (![value isEqualToString:_backedTextInputView.attributedText.string]) {
|
||||
if (value && ![value isEqualToString:_backedTextInputView.attributedText.string]) {
|
||||
NSAttributedString *attributedString =
|
||||
[[NSAttributedString alloc] initWithString:value attributes:_backedTextInputView.defaultTextAttributes];
|
||||
[self _setAttributedString:attributedString];
|
||||
|
||||
+5
-4
@@ -288,16 +288,17 @@ public class ReactTextInputManager extends BaseViewManager<ReactEditText, Layout
|
||||
return;
|
||||
}
|
||||
|
||||
String text = args.getString(1);
|
||||
|
||||
int start = args.getInt(2);
|
||||
int end = args.getInt(3);
|
||||
if (end == UNSET) {
|
||||
end = start;
|
||||
}
|
||||
|
||||
reactEditText.maybeSetTextFromJS(
|
||||
getReactTextUpdate(text, mostRecentEventCount, start, end));
|
||||
if (!args.isNull(1)) {
|
||||
String text = args.getString(1);
|
||||
reactEditText.maybeSetTextFromJS(
|
||||
getReactTextUpdate(text, mostRecentEventCount, start, end));
|
||||
}
|
||||
reactEditText.maybeSetSelection(mostRecentEventCount, start, end);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user