diff --git a/patches/react-native-keyboard-controller@1.22.8.patch b/patches/react-native-keyboard-controller@1.22.8.patch index 3f307d3202cd..4c13280a6ed1 100644 --- a/patches/react-native-keyboard-controller@1.22.8.patch +++ b/patches/react-native-keyboard-controller@1.22.8.patch @@ -1,3 +1,90 @@ +diff --git a/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift b/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift +index cdbd633..41a72bc 100644 +--- a/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift ++++ b/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift +@@ -25,6 +25,12 @@ public extension KeyboardMovementObserver { + name: UIResponder.keyboardWillShowNotification, + object: nil + ) ++ NotificationCenter.default.addObserver( ++ self, ++ selector: #selector(keyboardWillChangeFrame), ++ name: UIResponder.keyboardWillChangeFrameNotification, ++ object: nil ++ ) + } + + @objc func unmount() { +diff --git a/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift b/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift +index 545a5b2..fbdc984 100644 +--- a/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift ++++ b/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift +@@ -8,6 +8,12 @@ + extension KeyboardMovementObserver { + @objc func keyboardWillAppear(_ notification: Notification) { + guard !UIResponder.isKeyboardPreloading else { return } ++ floatingHideTask?.cancel() ++ ++ if isFloatingKeyboard(notification) { ++ hideIfKeyboardShown(notification) ++ return ++ } + + let (duration, frame) = notification.keyboardMetaData() + if let keyboardFrame = frame { +@@ -36,8 +42,40 @@ extension KeyboardMovementObserver { + } + } + ++ @objc func keyboardWillChangeFrame(_ notification: Notification) { ++ guard !UIResponder.isKeyboardPreloading, isFloatingKeyboard(notification) else { return } ++ // runs after a willShow/willHide posted with this notification, which cancel it, so hide events fire once ++ floatingHideTask?.cancel() ++ let task = DispatchWorkItem { [weak self] in ++ self?.hideIfKeyboardShown(notification) ++ } ++ floatingHideTask = task ++ DispatchQueue.main.async(execute: task) ++ } ++ ++ // iPadOS floating and minimized keyboards are narrower than the screen or end above the app's bottom, so ++ // they cover no app content; UIKit switches to them without willHide, so they must count as hidden. ++ private func isFloatingKeyboard(_ notification: Notification) -> Bool { ++ guard let frame = notification.keyboardMetaData().1?.cgRectValue, !frame.isEmpty else { return false } ++ let screen = (notification.object as? UIScreen ?? UIScreen.main).bounds ++ // in Slide Over a docked keyboard ends at the app window's bottom, above the screen's ++ let windowBottom = UIApplication.shared.activeWindow.map { ++ $0.convert($0.bounds, to: $0.screen.coordinateSpace).maxY ++ } ?? screen.height ++ let dockedBottom = min(screen.height, windowBottom) ++ return frame.width.rounded() < screen.width.rounded() || frame.maxY.rounded() < dockedBottom.rounded() ++ } ++ ++ private func hideIfKeyboardShown(_ notification: Notification) { ++ let targetHeight = self.notification?.keyboardMetaData().1?.cgRectValue.height ?? 0 ++ if targetHeight > 0 { ++ keyboardWillDisappear(notification) ++ } ++ } ++ + @objc func keyboardWillDisappear(_ notification: Notification) { + guard !UIResponder.isKeyboardPreloading else { return } ++ floatingHideTask?.cancel() + let (duration, _) = notification.keyboardMetaData() + tag = UIResponder.current.reactViewTag + self.notification = notification +diff --git a/ios/observers/movement/observer/KeyboardMovementObserver.swift b/ios/observers/movement/observer/KeyboardMovementObserver.swift +index ae97d61..2ea1d2d 100644 +--- a/ios/observers/movement/observer/KeyboardMovementObserver.swift ++++ b/ios/observers/movement/observer/KeyboardMovementObserver.swift +@@ -37,6 +37,7 @@ public class KeyboardMovementObserver: NSObject { + // manual did events + var notification: Notification? + var keyboardDidTask: DispatchWorkItem? ++ var floatingHideTask: DispatchWorkItem? + + @objc public init( + handler: @escaping (NSString, NSNumber, NSNumber, NSNumber, NSNumber) -> Void, diff --git a/lib/commonjs/components/KeyboardChatScrollView/index.js b/lib/commonjs/components/KeyboardChatScrollView/index.js index 0b78ff3..98b3b6c 100644 --- a/lib/commonjs/components/KeyboardChatScrollView/index.js diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 71ad239cc0d3..5ef8d89bd907 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -384,7 +384,7 @@ patchedDependencies: node-pty@1.2.0-beta.15: f1e680afec85f650699ea756f91f469844ec4c976f4f168492a45c6b3f67d651 react-native-gesture-handler@3.3.0: abe20e1d1c23549297cbbc818e14fe479b41455930d9663135d6b40fe359b626 react-native-image-viewing@0.2.2: 4aa038d541c7ddcc8f1437eb3e7b4f769f61de78e7f91b53f9805dfca608474d - react-native-keyboard-controller@1.22.8: 6eb6c847ac693b636ec97c83575acd44b77e92ad0d2c776de0cb4e78e8fb9d4f + react-native-keyboard-controller@1.22.8: 3fa3d03e203a23165a439c4cddf5372ccd53acf337389793211be64dcdafccef react-native-pdf-jsi@5.0.0: 6f52854210f61bef499850ebd498229a111bc34ec5b2a4925e644f2f48f42760 react-native-reanimated@4.7.1: 95ee26e5fcab5f50bc4b4c47b3f7e6278a0b20850205efb9f6ee7e70a22d2b59 react-native-webview@14.0.1: 81caa279ec3dc1f81209062133b66e8f824e13f106cca57f1fa732a72c2ab378 @@ -745,7 +745,7 @@ importers: version: 0.2.2(patch_hash=4aa038d541c7ddcc8f1437eb3e7b4f769f61de78e7f91b53f9805dfca608474d)(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0) react-native-keyboard-controller: specifier: 1.22.8 - version: 1.22.8(patch_hash=6eb6c847ac693b636ec97c83575acd44b77e92ad0d2c776de0cb4e78e8fb9d4f)(e2a826d844fe10cdcbda558127861778) + version: 1.22.8(patch_hash=3fa3d03e203a23165a439c4cddf5372ccd53acf337389793211be64dcdafccef)(e2a826d844fe10cdcbda558127861778) react-native-nitro-modules: specifier: 0.37.1 version: 0.37.1(react-native@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(react@19.3.0) @@ -20986,7 +20986,7 @@ snapshots: react: 19.3.0 react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6) - react-native-keyboard-controller@1.22.8(patch_hash=6eb6c847ac693b636ec97c83575acd44b77e92ad0d2c776de0cb4e78e8fb9d4f)(e2a826d844fe10cdcbda558127861778): + react-native-keyboard-controller@1.22.8(patch_hash=3fa3d03e203a23165a439c4cddf5372ccd53acf337389793211be64dcdafccef)(e2a826d844fe10cdcbda558127861778): dependencies: react: 19.3.0 react-native: 0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(@react-native/metro-config@0.88.0(@babel/core@7.29.7(supports-color@8.1.1))(bufferutil@4.1.0)(supports-color@8.1.1)(utf-8-validate@6.0.6))(@types/react@19.3.0)(bufferutil@4.1.0)(react@19.3.0)(supports-color@8.1.1)(utf-8-validate@6.0.6)