react-native-merlin icon indicating copy to clipboard operation
react-native-merlin copied to clipboard

Add disabled to Input

Open MSchmidt opened this issue 4 years ago • 7 comments

It would be nice to have support for disabled on Form.Input to be more in line with HTML forms.

MSchmidt avatar Dec 11 '20 12:12 MSchmidt

Hi!

This should currently be possible since Merlin will just pass through any props that it's not using down to the input element. In React Native it would be editable instead of disabled to stop people from interacting with the input. Unless you mean disabling it in some other way?

You can take a look at the docs for the default input that Merlin uses: https://reactnative.dev/docs/textinput#editable

And an example of how that would work (I've specified the as but it defaults to TextInput):

<Form>
  ...
  <Form.Input as={TextInput} editable={false} />
</Form>

hparton avatar Dec 11 '20 12:12 hparton

Ah yeah I see. Thanks. Half way there. However, this confuses the automatic keyboard next/done-button handling. I'm trying to understand how to customise the keyboard behaviour.

MSchmidt avatar Dec 11 '20 12:12 MSchmidt

Ah that will be an issue with that I guess. I should have some time to take a look at that in the next few days and I'll let you know when a fix is out.

hparton avatar Dec 11 '20 12:12 hparton

Yeah no hurry :) Already great to get such a quick response here. Thanks a ton. I'm currently trying to adjust returnKeyType myself but doesn't seem to work since merlinProps override other props.

MSchmidt avatar Dec 11 '20 13:12 MSchmidt

Will have a look at the behavior when setting a default input as disabled and how that's handled with the keyboard input but also need to take a look at exposing a way to define custom behavior for it. I could see it being useful on custom components that you might want to skip over or pass the focus inside of.

hparton avatar Dec 11 '20 16:12 hparton

Absolutely. Custom Inputs could benefit from this but regular forms as well. I for example have a form I do not want to submit right after filling all the fields. The keyboard button on the final field should only hide the keyboard.

MSchmidt avatar Dec 14 '20 07:12 MSchmidt

@MSchmidt I put in a PR for being able to manually override the returnKeyType https://github.com/hparton/react-native-merlin/pull/22

sambeevors avatar Apr 22 '21 13:04 sambeevors