From 0fa41b48c75a6e780c601ca58a8633eed72ceba0 Mon Sep 17 00:00:00 2001 From: Vit Horacek <36083550+mountiny@users.noreply.github.com> Date: Mon, 2 Dec 2024 17:01:48 +0100 Subject: [PATCH] Merge pull request #53384 from margelo/fix/fallback-to-current-focus-activity-on-android-keyboard-controller (cherry picked from commit cb0613c083baa987c63a5bdd724a729c5a1795b8) (CP triggered by puneetlath) --- src/utils/keyboard.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/utils/keyboard.ts b/src/utils/keyboard.ts index ed1df0efc700..a2b1d329aa0a 100644 --- a/src/utils/keyboard.ts +++ b/src/utils/keyboard.ts @@ -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 react-native-keyboard-controller@1.15+ we can use `KeyboardController.dismiss()` directly const dismiss = (): Promise => { return new Promise((resolve) => { if (!isVisible) { @@ -19,12 +18,12 @@ const dismiss = (): Promise => { return; } - const subscription = KeyboardEvents.addListener('keyboardDidHide', () => { + const subscription = Keyboard.addListener('keyboardDidHide', () => { resolve(undefined); subscription.remove(); }); - KeyboardController.dismiss(); + Keyboard.dismiss(); }); };