Commit 692494f
authored
feat: dismiss without animation (#1127)
## 📜 Description
Added ability to hide keyboard instantly.
## 💡 Motivation and Context
This PR has been inspired by this post in twitter:
https://x.com/klemensstrasser/status/1955284572825853957?t=Rui36_sZCd3pEoKFc02N9w&s=35
In this particular transition it makes sense to instantly hide the
keyboard, so that main shared transition look consistent and additional
animations don't distract the attention. So in this PR I'm adding a new
option to `dismiss` method: `animated`. You can specify `false` and then
keyboard will be dismissed instantly. By default this option is `true`,
but when you develop complex shared animation transitions it may make
sense to hide keyboard immediately 👀
The other reason why I am adding this is because I've seen in some
projects (Expensify, for example) that keyboard **may** be hidden
instantly in some edge cases (that was a reminder that you need to use
`onEnd` for sync last animation frame). Now this is not the edge case,
but something that we can control as well - so it will be easier to test
various components, such as
`KeyboardAvoidingView`/`KeyboardAwareScrollView` to assure they work
consistently with immediate close too.
## 📢 Changelog
<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->
### E2E
- added new test for testing instant hide;
- updated assets for close functionality;
### Docs
- added a note that you can hide keyboard without animation;
### JS
- added `animated` prop to `types.ts`.
### iOS
- hide keyboard using `performWithoutAnimation` if `animated` is `true`.
### Android
- hide keyboard using `WindowInsetsController` if `animated` is `true`.
## 🤔 How Has This Been Tested?
Tested on:
- Pixel 7 Pro (Android 16);
- iPhone 16 Pro (iOS 18).
## 📸 Screenshots (if appropriate):
|Android|iOS|
|--------|---|
|<video
src="https://github.com/user-attachments/assets/73ae03a3-d69b-469a-80de-0b21852fcf2c">|<video
src="https://github.com/user-attachments/assets/0590365c-d6d7-46ce-8458-2855a227c5a9">|
## 📝 Checklist
- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed1 parent 8138c60 commit 692494f
File tree
30 files changed
+110
-34
lines changed- FabricExample/src/screens/Examples/Close
- android/src
- fabric/java/com/reactnativekeyboardcontroller
- main/java/com/reactnativekeyboardcontroller/modules
- paper/java/com/reactnativekeyboardcontroller
- docs/docs/api
- e2e/kit
- assets
- android
- e2e_emulator_28
- e2e_emulator_31
- ios
- iPhone 13 Pro
- iPhone 14 Pro
- iPhone 15 Pro
- iPhone 16 Pro
- example/src/screens/Examples/Close
- ios
- src
- specs
- types
30 files changed
+110
-34
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
18 | 19 | | |
19 | 20 | | |
20 | 21 | | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
36 | 42 | | |
37 | 43 | | |
38 | 44 | | |
39 | | - | |
| 45 | + | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
27 | 30 | | |
28 | 31 | | |
29 | 32 | | |
| |||
Lines changed: 25 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
4 | 5 | | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
14 | 16 | | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
| |||
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
29 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
30 | 36 | | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
34 | 40 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
39 | 59 | | |
40 | 60 | | |
41 | 61 | | |
| |||
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
32 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
33 | 36 | | |
34 | 37 | | |
35 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
85 | 91 | | |
86 | 92 | | |
87 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
64 | 81 | | |
0 commit comments