From 21790bbd0ab180fc83724e9a4fc2a99629a35552 Mon Sep 17 00:00:00 2001 From: Marshall Gould Date: Mon, 13 Jul 2026 17:42:47 +0100 Subject: [PATCH] fix: tolerate fractional iOS keyboard positions --- ios/observers/movement/KeyboardTrackingView.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/ios/observers/movement/KeyboardTrackingView.swift b/ios/observers/movement/KeyboardTrackingView.swift index 1b0e3e6a49..b6d9f8276d 100644 --- a/ios/observers/movement/KeyboardTrackingView.swift +++ b/ios/observers/movement/KeyboardTrackingView.swift @@ -138,12 +138,17 @@ public final class KeyboardTrackingView: UIView { // for `keyboardLayoutGuide` case we can just read keyboard position directly - no interpolation needed if KeyboardControllerConfiguration.usesKeyboardLayoutGuideTracking { - if keyboardPosition > keyboardHeight { + // when we are the top position KVO takes `inputAccessoryView` into consideration, + // so we handle it here. KVO reports coordinates on the screen's pixel + // grid, while `keyboardHeight` can include a fractional accessory-view + // offset (for example, a hairline border). Treat values within one pixel + // as the same fully-open position instead of relying on exact equality. + let screenScale = trackedView.window?.screen.scale ?? UIScreen.main.scale + let positionTolerance = 1 / max(screenScale, 1) + if keyboardPosition > keyboardHeight + positionTolerance { return Self.invalidPosition } - // when we are the top position KVO takes `inputAccessoryView` into consideration, - // so we handle it here - if keyboardPosition == keyboardHeight { + if abs(keyboardPosition - keyboardHeight) <= positionTolerance { return keyboardPosition - KeyboardAreaExtender.shared.offset } return keyboardPosition