question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TextInput editable prop doesn't work

See original GitHub issue

Current behaviour

I can edit the not editable TextInput

Expected behaviour

I shouldn’t be able to edit the TextInput

Code sample

import React from 'react';
import { StyleSheet, View } from 'react-native';
import { TextInput as TextInputPaper } from 'react-native-paper';

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <TextInputPaper
          label='Flat input'
        />
        <TextInputPaper
          label='Flat input not editable'
          editable={false}
        />
        <TextInputPaper
          label='Outlined input'
          mode='outlined'
        />
        <TextInputPaper
          label='Outlined input not editable'
          mode='outlined'
          editable={false}
        />
    </View>
      );
  }
}

Screenshots

screenshot 2019-01-18 at 17 29 31

Your Environment

software version
ios or android 12.1
react-native latest
react-native-paper latest

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
macfanaticcommented, May 22, 2020

Using a TouchableWithoutFeedback to wrap the non-editable TextInput works well on iOS, but on Android the text input itself doesn’t fire any events. You have to tap on a very small area of the overall containing view to get the event to fire.

In this example, I have a red background to show the area tappable.

<TouchableOpacity onPress={presentStatePicker} style={{backgroundColor: 'red'}}>
   <TextInput label="Province" mode="outlined" style={styles.input} value={form.province} editable={false} onTouchStart={presentStatePicker} />
</TouchableOpacity>

Screen Shot 2020-05-22 at 4 26 37 PM

Any thoughts @Jack0815 or @satya164 ?

0reactions
ChristosApatsidiscommented, Oct 5, 2020

I have the same issue, In my case i remove flex: 1 from style and issue fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Making a react-native TextInput readonly - Stack Overflow
I want to make a text input readonly in my RN application. I tried to set an editable prop but it did not...
Read more >
TextInput - React Native
TextInput. A foundational component for inputting text into the app via a keyboard. Props provide configurability for several features, ...
Read more >
TextInput · React Native Paper
A component to allow users to input text. ... If true, user won't be able to interact with the component. label. Type: TextInputLabelProp....
Read more >
A complete guide to TextInput in React Native - LogRocket Blog
Learn how to implement React Native's TextInput component, customize it to collect user inputs, and style your fields with React Native ...
Read more >
Accessible React Native TextInput - Hinge Health
How to build an accessible text input in React Native ... When I run this on my iOS device I don't hear the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found