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] How to show "Done" button above "number-pad" keyboard? #1190

Closed
ranyefet opened this issue May 7, 2015 · 53 comments
Closed

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

ranyefet opened this issue May 7, 2015 · 53 comments
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@ranyefet
Copy link

ranyefet commented May 7, 2015

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})}
              />
@brentvatne
Copy link
Collaborator

@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

@ide
Copy link
Contributor

ide commented May 7, 2015

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

@ranyefet
Copy link
Author

ranyefet commented May 8, 2015

@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?

@ide
Copy link
Contributor

ide commented May 8, 2015

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.

@brentvatne brentvatne changed the title How to show "Done" button above "number-pad" keyboard? [TextInput] How to show "Done" button above "number-pad" keyboard? May 30, 2015
@auser
Copy link

auser commented Jun 1, 2015

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

@brentvatne
Copy link
Collaborator

Let's collapse this issue into #371

@henrikra
Copy link

@auser Are you still working on inputAccessoryView?

@gwendall
Copy link

+1

2 similar comments
@kelset
Copy link
Contributor

kelset commented Jan 25, 2017

+1

@stief510
Copy link

+1

@kelset
Copy link
Contributor

kelset commented Jan 27, 2017

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

@mileung
Copy link

mileung commented Jan 30, 2017

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

@Burak07
Copy link

Burak07 commented Feb 22, 2017

+1 still looking forward

@MobiusHorizons
Copy link

+1

5 similar comments
@filipemonteiroth
Copy link

+1

@JasonHenson
Copy link

+1

@aldasvn
Copy link

aldasvn commented Apr 18, 2017

+1

@Amir-Taboul
Copy link

+1

@rahulbats
Copy link

+1

@henrikra
Copy link

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

@lavarajallu
Copy link

lavarajallu commented Apr 26, 2017

in your textInput just u have pass this property
returnKeyType='done'

@henrikra
Copy link

@lavarajallu This does not work when using keyboardType="number-pad"

@jhalborg
Copy link

+1

@JasonHenson
Copy link

+1 this would be a great addition

@kitolog
Copy link

kitolog commented Jun 12, 2017

+1

2 similar comments
@enstulen
Copy link

+1

@ptz3233
Copy link

ptz3233 commented Jun 19, 2017

+1

@bkdev98
Copy link

bkdev98 commented Jun 22, 2017

+1

2 similar comments
@rskull
Copy link

rskull commented Jun 23, 2017

+1

@dmr07
Copy link

dmr07 commented Jun 24, 2017

+1

@luco
Copy link

luco commented Jun 25, 2017

Not a single PR yet?

@nntai
Copy link

nntai commented Jun 27, 2017

+1

2 similar comments
@irrigator
Copy link

+1

@jnrepo
Copy link

jnrepo commented Jun 27, 2017

+1

facebook-github-bot pushed a commit that referenced this issue Jun 27, 2017
…n iOS

Summary:
Standard only-numeric (number pad) keyboard on iOS does not have any "Done" or "Enter" button, and this is often very badly hurt user experience.
Usually it can be solved by implementing custom `inputAccessoryView`, but RN does not have built-in support for customizing it.
So, this commit introduced limited support only for "Done" button (returnKeyType="done") and it should suite very well for the vast majority of use cases.
This is highly requested feature, see more details here:
#1190

Reviewed By: mmmulani

Differential Revision: D5268020

fbshipit-source-id: 90bd5bffac6aaa1fb7c5c2ac539b35b04d45918f
@JohnProg
Copy link

+1

sayar pushed a commit to microsoft/react-native-windows that referenced this issue Jul 26, 2017
…n iOS

Summary:
Standard only-numeric (number pad) keyboard on iOS does not have any "Done" or "Enter" button, and this is often very badly hurt user experience.
Usually it can be solved by implementing custom `inputAccessoryView`, but RN does not have built-in support for customizing it.
So, this commit introduced limited support only for "Done" button (returnKeyType="done") and it should suite very well for the vast majority of use cases.
This is highly requested feature, see more details here:
facebook/react-native#1190

Reviewed By: mmmulani

Differential Revision: D5268020

fbshipit-source-id: 90bd5bffac6aaa1fb7c5c2ac539b35b04d45918f
@beeant
Copy link

beeant commented Jul 31, 2017

+1

2 similar comments
@sakarit-zz
Copy link

+1

@AnisDerbel
Copy link

+1

@stief510
Copy link

@marcioadr88
Copy link

marcioadr88 commented Aug 28, 2017

The "Done" button is always shown in english? The phone (simulator) lang is in spanish and the button should display as "Hecho". I have this issue only on iOS.

@NicholasBertazzon
Copy link

@marcioadr88 You need to add support for the localizations. See http://www.ibabbleon.com/iphone_app_localization.html

@marcioadr88
Copy link

It works, thanks @NicholasBertazzon

@renso3x
Copy link

renso3x commented Nov 22, 2017

Here you can add next also https://gist.github.com/renso3x/2939df594d8571ccfe23aa9bd70e96d7

@maryammouse
Copy link

+1

2 similar comments
@celodauane
Copy link

+1

@KangYoosam
Copy link

+1

@savagesnake
Copy link

savagesnake commented Jan 25, 2018

returnKeyType='done' works with "number-pad" and "numeric" on v0.47.1

@w-
Copy link

w- commented Feb 15, 2018

+1

1 similar comment
@w-
Copy link

w- commented Feb 28, 2018

+1

@TheMonster1995
Copy link

I have the same problem trying to show "Next" using return key type, and it just doesn't show. Any ideas? This problem only exists on numeric pad, or any other kind of keyboard that shows only the numbers - it works just fine with normal keyboard.

@PROudoxa
Copy link

@egemon
Copy link

egemon commented May 3, 2018

Are there any native solutions for custom top bar for any type of keyboard?

@PROudoxa
Copy link

PROudoxa commented May 3, 2018

egedemon, i've seen your profile and i guess you are looking for JS solutions...I can't help you with JS.
But might be following way will be interesting for someone else - for ios(swift):

override func viewDidLoad() {
super.viewDidLoad()
//init toolbar
let toolbar:UIToolbar = UIToolbar(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 30))
//create left side empty space so that done button set on right side
let flexSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let doneBtn: UIBarButtonItem = UIBarButtonItem(title: “Done”, style: .done, target: self, action: Selector(“doneButtonAction”))
toolbar.setItems([flexSpace, doneBtn], animated: false)
toolbar.sizeToFit()
//setting toolbar as inputAccessoryView
self.textField1.inputAccessoryView = toolbar // add any textField
self.textField2.inputAccessoryView = toolbar // add your textField
}
func doneButtonAction() {
self.view.endEditing(true)
}
https://medium.com/@KaushElsewhere/how-to-dismiss-keyboard-in-a-view-controller-of-ios-3b1bfe973ad1

@facebook facebook locked as resolved and limited conversation to collaborators Jun 1, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests