diff --git a/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt b/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt index d01aa7289..086b5d8e9 100644 --- a/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt +++ b/android/src/main/java/com/swmansion/enriched/EnrichedTextInputView.kt @@ -54,6 +54,7 @@ class EnrichedTextInputView : AppCompatEditText { val parametrizedStyles: ParametrizedStyles? = ParametrizedStyles(this) var isDuringTransaction: Boolean = false var isRemovingMany: Boolean = false + var scrollEnabled: Boolean = true val mentionHandler: MentionHandler? = MentionHandler(this) var htmlStyle: HtmlStyle = HtmlStyle(this, null) @@ -139,6 +140,14 @@ class EnrichedTextInputView : AppCompatEditText { return super.onTouchEvent(ev) } + override fun canScrollVertically(direction: Int): Boolean { + return scrollEnabled + } + + override fun canScrollHorizontally(direction: Int): Boolean { + return scrollEnabled + } + override fun onSelectionChanged(selStart: Int, selEnd: Int) { super.onSelectionChanged(selStart, selEnd) selection?.onSelection(selStart, selEnd) diff --git a/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt b/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt index aba765359..8b5a2296b 100644 --- a/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt +++ b/android/src/main/java/com/swmansion/enriched/EnrichedTextInputViewManager.kt @@ -154,6 +154,11 @@ class EnrichedTextInputViewManager : SimpleViewManager(), view?.setFontStyle(style) } + @ReactProp(name = "scrollEnabled") + override fun setScrollEnabled(view: EnrichedTextInputView, scrollEnabled: Boolean) { + view.scrollEnabled = scrollEnabled + } + override fun onAfterUpdateTransaction(view: EnrichedTextInputView) { super.onAfterUpdateTransaction(view) view.afterUpdateTransaction() diff --git a/ios/EnrichedTextInputView.mm b/ios/EnrichedTextInputView.mm index df6783fed..027b5b93f 100644 --- a/ios/EnrichedTextInputView.mm +++ b/ios/EnrichedTextInputView.mm @@ -358,6 +358,10 @@ - (void)updateProps:(Props::Shared const &)props oldProps:(Props::Shared const & stylePropChanged = YES; } + if(newViewProps.scrollEnabled != oldViewProps.scrollEnabled || textView.scrollEnabled != newViewProps.scrollEnabled) { + [textView setScrollEnabled:newViewProps.scrollEnabled]; + } + folly::dynamic oldMentionStyle = oldViewProps.htmlStyle.mention; folly::dynamic newMentionStyle = newViewProps.htmlStyle.mention; if(oldMentionStyle != newMentionStyle) { diff --git a/src/EnrichedTextInput.tsx b/src/EnrichedTextInput.tsx index 8ee4e2420..07f2d2fe2 100644 --- a/src/EnrichedTextInput.tsx +++ b/src/EnrichedTextInput.tsx @@ -130,6 +130,7 @@ export interface EnrichedTextInputProps extends Omit { autoCapitalize?: 'none' | 'sentences' | 'words' | 'characters'; htmlStyle?: HtmlStyle; style?: ViewStyle | TextStyle; + scrollEnabled?: boolean; onFocus?: () => void; onBlur?: () => void; onChangeText?: (e: NativeSyntheticEvent) => void; @@ -192,6 +193,7 @@ export const EnrichedTextInput = ({ onEndMention, onChangeSelection, androidExperimentalSynchronousEvents = false, + scrollEnabled = true, ...rest }: EnrichedTextInputProps) => { const nativeRef = useRef(null); @@ -352,6 +354,7 @@ export const EnrichedTextInput = ({ androidExperimentalSynchronousEvents={ androidExperimentalSynchronousEvents } + scrollEnabled={scrollEnabled} {...rest} /> ); diff --git a/src/EnrichedTextInputNativeComponent.ts b/src/EnrichedTextInputNativeComponent.ts index 34a9c5e39..e0b943201 100644 --- a/src/EnrichedTextInputNativeComponent.ts +++ b/src/EnrichedTextInputNativeComponent.ts @@ -135,6 +135,7 @@ export interface NativeProps extends ViewProps { selectionColor?: ColorValue; autoCapitalize?: string; htmlStyle?: HtmlStyleInternal; + scrollEnabled?: boolean; // event callbacks onInputFocus?: DirectEventHandler;