Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
📜 Description
Added
KeyboardController.dismiss
method.💡 Motivation and Context
Actually there is quite a lot of motivation behind such functionality. Let's go one-by one
1️⃣ Community request
In Algolia I constantly see that people are looking for
dismiss
method.2️⃣
react-native
flaws implementationreact-native
implementation is based on the next code:Where
currentlyFocusedInput
is set in:And the usage of this function:
So theoretically if you use
TextInput
component that is not based on the implementation fromreact-native
core (i. e. you decided to write your own component), thenKeyboard.dismiss
most likely will not work 😓3️⃣ Standalone module
I'm going to continue the development of this library and in the future I may need to rely on the presence/implementation of my own methods.
For example I'm thinking about
Toolbar
component implementation (the component above the keyboard with prev/next/done buttons). In my opinion it'll be strange when this component will fully depend on the methods from this package AND on a single function fromreact-native
Keyboard
module 🤔So I think it's better to have own equivalent.
📢 Changelog
Docs
setInputMode
/setDefaultMode
;dismiss
method;JS
dismiss
inspecs
,types
;mock
and unit-test;iOS
resignFirstResponder
selector to dismiss a keyboard (source);dismiss
method toKeyboardController
;Android
hideSoftInputFromWindow
to close a keyboard (source);dismiss
method toKeyboardController
;🤔 How Has This Been Tested?
Tested manually on:
📸 Screenshots (if appropriate):
Screen.Recording.2023-12-23.at.00.33.43.mov
Simulator.Screen.Recording.-.iPhone.15.Pro.-.2023-12-23.at.00.32.22.mp4
📝 Checklist