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

[TextInput] How to show "Done" button above "number-pad" keyboard?

Open ranyefet opened this issue 11 years ago • 53 comments

Hello,

I'm trying to implement the following screen: 2 2_verification_openkeypad_small

How can I get the bar above the keyboard to show up with "Done" button?

<TextInput
                style={styles.codeInput}
                placeholder="Enter Code"
                value={this.state.pinCode}
                keyboardType="number-pad"
                onChangeText={(code) => this.setState({pinCode: code})}
              />

ranyefet avatar May 07 '15 16:05 ranyefet

@ranyefet - you could listen to keyboard events and set the position of your Done button accordingly when it opens: https://github.com/johanneslumpe/react-native-keyboardevents - there may be a more elegant way but this will work

brentvatne avatar May 07 '15 18:05 brentvatne

You want what's called the input accessory but it's not yet built yet.

ide avatar May 07 '15 20:05 ide

@brentvatne @ide Thanks for the comments. The reason why I wanted the "Done" button is because in the iOS Simulator I wasn't able to close the keypad by clicking anywhere on the screen. The only way to close the keypad was to hit Return on my mac keyboard. I haven't tested it yet on a real device, so I'm not sure what will happen there.

Do you know If this is a bug with the simulator, or do I need to implement this functionality with code?

ranyefet avatar May 08 '15 09:05 ranyefet

You should implement/configure it in code. The keyboard is very manual on iOS. ScrollView has some prop that lets you auto-dismiss the keyboard that you might want to look into.

ide avatar May 08 '15 10:05 ide

I'm working on adding the inputAccessoryView on IOS. I'll update this issue when I have a PR.

auser avatar Jun 01 '15 17:06 auser

Let's collapse this issue into #371

brentvatne avatar Jun 01 '15 17:06 brentvatne

@auser Are you still working on inputAccessoryView?

henrikra avatar Jan 19 '17 11:01 henrikra

+1

gwendall avatar Jan 21 '17 17:01 gwendall

+1

kelset avatar Jan 25 '17 10:01 kelset

+1

arstiefel avatar Jan 26 '17 14:01 arstiefel

As a temporary workaround I found this lib which works pretty well, but forces you to have the separated files (ex. component.ios.js & component.android.ios) for the components which use it: https://github.com/DickyT/react-native-textinput-utils

kelset avatar Jan 27 '17 16:01 kelset

I just made a keyboard dismissing component for number keyboard on iOS called DoneBar if anyone wants to give it a try.

mileung avatar Jan 30 '17 22:01 mileung

+1 still looking forward

Burak07 avatar Feb 22 '17 12:02 Burak07

+1

MobiusHorizons avatar Mar 06 '17 14:03 MobiusHorizons

+1

filipemonteiroth avatar Mar 12 '17 21:03 filipemonteiroth

+1

JasonHenson avatar Mar 30 '17 18:03 JasonHenson

+1

aldasvn avatar Apr 18 '17 10:04 aldasvn

+1

Amir-Taboul avatar Apr 22 '17 19:04 Amir-Taboul

+1

rahulbats avatar Apr 25 '17 04:04 rahulbats

Here is implementation for this feature https://gist.github.com/chih/3aa8b3bbd490137a31f0b864eff1532e Now we just need someone to make PR out of it :)

Here is also video on the implementation https://www.youtube.com/watch?v=RuzHai2RVZU

henrikra avatar Apr 25 '17 05:04 henrikra