From 610412385b1b256b11db3751a66fc614747c96cd Mon Sep 17 00:00:00 2001 From: Johannes Baldursson Date: Wed, 8 Aug 2018 18:32:18 -0700 Subject: [PATCH] Exposed scrollEnabled on TextInput (#19330) Summary: On iOS, it is not possible to select a range of text using a `Text` component (see #13938). Because of how the `Text` component is implemented on iOS, this will not work without a complete re-write. On Android however, this is not an issue. As the `TextInput` component has evolved, it can more or less be used as a drop-in replacement on iOS by setting `multiline={true}` and `editable={false}`. Except for one detail: the text input field has scrolling activated and it's not possible to turn off. (See #1391 and #15962). This pull request addresses that issue, simply by exposing the `scrollEnabled` property: ``` ``` 1. Create a multiline `TextInput` component, with the attributes presented above. 2. Run on iOS 3. The `TextInput` field should not be able to scroll facebook/react-native-website#367 [IOS] [FEATURE] [TextInput] - Made it possible to turn off scrolling on a multiline TextInput component Pull Request resolved: https://github.com/facebook/react-native/pull/19330 Differential Revision: D9235061 Pulled By: hramos fbshipit-source-id: 99d278004fc236b47dde7e61d74c71e8a3b9d170 --- Libraries/Components/TextInput/TextInput.js | 6 ++++++ Libraries/Text/TextInput/RCTBaseTextInputViewManager.m | 1 + 2 files changed, 7 insertions(+) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 178821b3ad7042..162119b5506960 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -581,6 +581,12 @@ const TextInput = createReactClass({ * The text color of the placeholder string. */ placeholderTextColor: ColorPropType, + /** + * If `false`, scrolling of the text view will be disabled. + * The default value is `true`. Does only work with 'multiline={true}'. + * @platform ios + */ + scrollEnabled: PropTypes.bool, /** * If `true`, the text input obscures the text entered so that sensitive text * like passwords stay secure. The default value is `false`. Does not work with 'multiline={true}'. diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index d5c49328042812..9d0789b450a9f0 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -48,6 +48,7 @@ @implementation RCTBaseTextInputViewManager RCT_REMAP_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) RCT_REMAP_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) RCT_REMAP_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode) +RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL) RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL) RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType)