-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53384 from margelo/fix/fallback-to-current-focus-…
…activity-on-android-keyboard-controller
- Loading branch information
Showing
1 changed file
with
5 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import {KeyboardController, KeyboardEvents} from 'react-native-keyboard-controller'; | ||
import {Keyboard} from 'react-native'; | ||
|
||
let isVisible = false; | ||
|
||
KeyboardEvents.addListener('keyboardDidHide', () => { | ||
Keyboard.addListener('keyboardDidHide', () => { | ||
isVisible = false; | ||
}); | ||
|
||
KeyboardEvents.addListener('keyboardDidShow', () => { | ||
Keyboard.addListener('keyboardDidShow', () => { | ||
isVisible = true; | ||
}); | ||
|
||
// starting from [email protected]+ we can use `KeyboardController.dismiss()` directly | ||
const dismiss = (): Promise<void> => { | ||
return new Promise((resolve) => { | ||
if (!isVisible) { | ||
|
@@ -19,12 +18,12 @@ const dismiss = (): Promise<void> => { | |
return; | ||
} | ||
|
||
const subscription = KeyboardEvents.addListener('keyboardDidHide', () => { | ||
const subscription = Keyboard.addListener('keyboardDidHide', () => { | ||
resolve(undefined); | ||
subscription.remove(); | ||
}); | ||
|
||
KeyboardController.dismiss(); | ||
Keyboard.dismiss(); | ||
}); | ||
}; | ||
|
||
|