danish1658 / react-native-dropdown-select-list

☝️ React Native Select List Equivalent to Html's Select with options"
https://www.npmjs.com/package/react-native-dropdown-select-list
MIT License
200 stars 89 forks source link

Add Keyboard.dismiss() option #23

Closed multi-vit closed 1 year ago

multi-vit commented 1 year ago

I'm using your excellent dropdown select (thank you!) as part of a wider form and would love it if I were able to dismiss the open keyboard on pressing the dropdown.

For example, if I've just entered something in a TextInput on the form and then want to select from this element, upon the dropdown opening the keyboard remains open and the first time I try and select an option from the dropdown, that dismisses the keyboard and doesn't actually select the option, I then have to select it again.

I tried to circumvent the need to add it to this repo by wrapping the element with a Touchable that has an onPress of Keyboard.dismiss() but that isn't working. It also doesn't work when wrapping the entire element in a pre-defined HideKeyboard function as suggested here, though this does close the keyboard if you tap anywhere else except the component.

Unless there's another way to do it?

I'm using React-Native with Expo and currently seeing this behaviour on Android. I don't have the means to test it on iPhone at the moment.

I hacked together a little work around by modifying the index.tsx file:

Importing Keyboard on line 2 Adding Keyboard.dismiss() to the onPress function on line 215

Happy to submit this as a PR if you think always automatically closing the keyboard is of value, but the alternative is I thought you might want to add it as a customisable boolean option and my skills aren't at that level yet!

danish1658 commented 1 year ago

Brilliant, Its actually a good thing. I will definitely add this in the upcoming version, for now i will mark this as enhancement.