Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextInput - focusable but not editable #2151

Closed
gregfenton opened this issue Aug 24, 2020 · 7 comments
Closed

TextInput - focusable but not editable #2151

gregfenton opened this issue Aug 24, 2020 · 7 comments
Labels

Comments

@gregfenton
Copy link
Contributor

gregfenton commented Aug 24, 2020

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

@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • react-native
  • react-native-paper
  • react-native-vector-icons

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • react-native-vector-icons

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • react-native (found: 0.62.2, latest: 0.63.2)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@github-actions
Copy link

Couldn't find version numbers for the following packages in the issue:

  • react-native-vector-icons

Can you update the issue to include version numbers for those packages? The version numbers must match the format 1.2.3.

The versions mentioned in the issue for the following packages differ from the latest versions on npm:

  • expo (found: 38.0.8, latest: 38.0.9)
  • react-native (found: 0.62.2, latest: 0.63.2)

Can you verify that the issue still exists after upgrading to the latest versions of these packages?

@kendallroth
Copy link

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.

@github-actions
Copy link

Hello 👋, this issue has been open for more than 2 months with no activity on it. If the issue is still present in the latest version, please leave a comment within 7 days to keep it open, otherwise it will be closed automatically. If you found a solution on workaround for the issue, please comment here for others to find. If this issue is critical for you, please consider sending a pull request to fix the issue.

@github-actions github-actions bot added the Stale label Oct 25, 2020
@kendallroth
Copy link

Uncertain if this is still necessary for @gregfenton, but I can still see applications for it.

@gregfenton
Copy link
Contributor Author

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 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants