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 - focusable but not editable

See original GitHub issue

Is your feature request related to a problem? Please describe.

A TextInput can be disabled={true} (grey text, no focus, no edit), and it can be editable={false} (normal color text, no focus, no edit). However, it would be very handy to allow focus while still not allowing editable.

Why? Because if the text is focusable, then it can be highlighted & copied to the clipboard (via standard OS capabilities).

Describe the solution you’d like Either make editable={false} allow focus, but not edit; or add a new setting to support as described above (focus but not edit).

Describe alternatives you’ve considered I have a TextInput with a onChangeText that simply returns the initial value passed into the component:

const myFocusableTextInput = ({initValue, label, mode}) => {
  const [text, setText] = useState(initValue);
  return (
    <TextInput label={label} value={text} mode={mode} onChangeText={(v) => setText(initValue)} />
  );
}

expo: 38.0.8 @expo/vector-icons 10.2.0 react-native: 0.62.2 react-native-paper: 4.0.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:8
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
kendallrothcommented, Aug 25, 2020

Another use case for this would be supporting a date picker input that should display a static (non-editable value) as well as a calendar icon. Pressing the right icon (calendar) can open the date picker dialog and should focus the field (to trigger validation on previous field, etc).

This is only possible currently by using editable={true} (ie. normal) and then passing in a value and setting `onChangeText={() => {}). However, this still can “allow” the user to appear to edit the field, although changes are immediately replaced with static value.

0reactions
gregfentoncommented, Oct 26, 2020

The workaround I listed above is … not a good UX. It is possible to wind up with weird behaviours based on timing issues because the control is actually allowing the user to interact with the value…it just overwrites what the user does with the initial value. Not a good solution.

Thanks for the ping @kendallroth !

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to force focus on TextInput with changable editable prop ...
I have a TextInput box I would like to display as Text. Then when it made editable by clicking the edit button, the...
Read more >
How to Make the Text Input Non-Editable - W3docs
In this snippet, you can find two methods of making a text input non-editable. Use either the HTML “readonly” attribute or add the...
Read more >
HTML5 Forms: Readonly Type Attribute - Wufoo
The readonly attribute makes a form control non-editable (or “read only”). A read-only field can't be modified, but, unlike disabled , you can...
Read more >
TextInput - React Native
Two methods exposed via the native element are .focus() and .blur() that will focus or blur the ... If false , text is...
Read more >
Combobox | APG | WAI - W3C
The one that most shapes interaction is text input. Some comboboxes allow users to type and edit text in the combobox and others...
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