0

When copying text with styles, the formatting is preserved when pasting into a TextInput. This issue only occurs on Android devices. Is it possible to disable copying with styles or is there any other solution to this problem?

Example: <Text selectable style={{color: '#fff'}}>some text sdfsdfsd <TextInput value={this.state.textInputMsg} style={{color: 'red'}} onChangeText={this.onChangeText} />

React Native Version

0.71.11

1 Answers1

0

To disable copying text with styles when pasting into a TextInput component on Android devices, you can utilize the removeClippedSubviews prop and set it to true for the TextInput component. This prop can help prevent the preservation of formatting styles when pasting text.

Here's an updated example of your code with the removeClippedSubviews prop added to the TextInput component:

<Text selectable style={{color: '#fff'}}>some text sdfsdfsd</Text>
<TextInput
  value={this.state.textInputMsg}
  style={{color: 'red'}}
  onChangeText={this.onChangeText}
  removeClippedSubviews={true}
/>

By setting removeClippedSubviews to true, it disables the preservation of styles when copying and pasting text into the TextInput component. This should help resolve the issue you mentioned.

Frankelly
  • 38
  • 7