Open History to see the last commit
1diff --git a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt
2--- a/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt
3+++ b/android/src/main/java/com/reactnativekeyboardcontroller/listeners/KeyboardAnimationCallback.kt
4@@ -66,6 +66,7 @@
5 // state variables
6 private var persistentKeyboardHeight = getCurrentKeyboardHeight()
7 private var prevKeyboardHeight = getCurrentKeyboardHeight()
8+ private var hasSyncedInitialState = false
9 private var isKeyboardVisible = false
10 private var isTransitioning = false
11 private var duration = 0
12@@ -176,7 +177,10 @@
13 // always verify insets, because sometimes default lifecycle methods may not be invoked
14 // (when we press "Share" on Android 16, when Modal closes keyboard, when permission Alert presented etc.)
15 val newHeight = getCurrentKeyboardHeight(insets)
16- if (prevKeyboardHeight != newHeight && !isMoving && !isSuspended) {
17+ // A callback for a recreated activity starts at the current height, so a keyboard JS still
18+ // counts as open (it closed while the old activity was gone) is never reported. Sync once.
19+ if ((prevKeyboardHeight != newHeight || !hasSyncedInitialState) && !isMoving && !isSuspended) {
20+ hasSyncedInitialState = true
21 Logger.w(
22 TAG,
23 "detected desynchronized state - force updating it: $newHeight",
24diff --git a/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift b/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift
25index cdbd63359be9c04fbb0cb30b3cbd1e399bb72d9a..41a72bcc5ebde85237e6aa6bd8240712fdebc0cd 100644
26--- a/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift
27+++ b/ios/observers/movement/observer/KeyboardMovementObserver+Lifecycle.swift
28@@ -25,6 +25,12 @@ public extension KeyboardMovementObserver {
29 name: UIResponder.keyboardWillShowNotification,
30 object: nil
31 )
32+ NotificationCenter.default.addObserver(
33+ self,
34+ selector: #selector(keyboardWillChangeFrame),
35+ name: UIResponder.keyboardWillChangeFrameNotification,
36+ object: nil
37+ )
38 }
40 @objc func unmount() {
41diff --git a/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift b/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift
42index 545a5b20f6caac289afdfd11cd7596d57de14122..fbdc9840113ee8caaac685d6f14d7d9f3c725c75 100644
43--- a/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift
44+++ b/ios/observers/movement/observer/KeyboardMovementObserver+Listeners.swift
45@@ -8,11 +8,17 @@
46 extension KeyboardMovementObserver {
47 @objc func keyboardWillAppear(_ notification: Notification) {
48 guard !UIResponder.isKeyboardPreloading else { return }
49+ floatingHideTask?.cancel()
50+
51+ if isFloatingKeyboard(notification) {
52+ hideIfKeyboardShown(notification)
53+ return
54+ }
56 let (duration, frame) = notification.keyboardMetaData()
57 if let keyboardFrame = frame {
58 tag = UIResponder.current.reactViewTag
59- let keyboardHeight = keyboardFrame.cgRectValue.size.height
60+ let keyboardHeight = heightOverlappingWindow(keyboardFrame.cgRectValue)
61 self.keyboardHeight = keyboardHeight
62 self.notification = notification
64@@ -36,8 +42,47 @@ extension KeyboardMovementObserver {
65 }
66 }
68+ @objc func keyboardWillChangeFrame(_ notification: Notification) {
69+ guard !UIResponder.isKeyboardPreloading, isFloatingKeyboard(notification) else { return }
70+ // runs after a willShow/willHide posted with this notification, which cancel it, so hide events fire once
71+ floatingHideTask?.cancel()
72+ let task = DispatchWorkItem { [weak self] in
73+ self?.hideIfKeyboardShown(notification)
74+ }
75+ floatingHideTask = task
76+ DispatchQueue.main.async(execute: task)
77+ }
78+
79+ // iPadOS floating and minimized keyboards are narrower than the screen or end above the app's bottom, so
80+ // they cover no app content; UIKit switches to them without willHide, so they must count as hidden.
81+ private func isFloatingKeyboard(_ notification: Notification) -> Bool {
82+ guard let frame = notification.keyboardMetaData().1?.cgRectValue, !frame.isEmpty else { return false }
83+ let screen = (notification.object as? UIScreen ?? UIScreen.main).bounds
84+ // in Slide Over a docked keyboard ends at the app window's bottom, above the screen's
85+ let windowBottom = UIApplication.shared.activeWindow.map {
86+ $0.convert($0.bounds, to: $0.screen.coordinateSpace).maxY
87+ } ?? screen.height
88+ let dockedBottom = min(screen.height, windowBottom)
89+ return frame.width.rounded() < screen.width.rounded() || frame.maxY.rounded() < dockedBottom.rounded()
90+ }
91+
92+ // the frame is screen-relative; a resized iPadOS window ends above the screen's bottom and covers only part of it
93+ private func heightOverlappingWindow(_ frame: CGRect) -> CGFloat {
94+ guard let window = UIApplication.shared.activeWindow else { return frame.height }
95+ let windowFrame = window.convert(window.bounds, to: window.screen.coordinateSpace)
96+ return max(0, min(frame.maxY, windowFrame.maxY) - max(frame.minY, windowFrame.minY))
97+ }
98+
99+ private func hideIfKeyboardShown(_ notification: Notification) {
100+ let targetHeight = self.notification?.keyboardMetaData().1?.cgRectValue.height ?? 0
101+ if targetHeight > 0 {
102+ keyboardWillDisappear(notification)
103+ }
104+ }
105+
106 @objc func keyboardWillDisappear(_ notification: Notification) {
107 guard !UIResponder.isKeyboardPreloading else { return }
108+ floatingHideTask?.cancel()
109 let (duration, _) = notification.keyboardMetaData()
110 tag = UIResponder.current.reactViewTag
111 self.notification = notification
112@@ -62,7 +107,7 @@ extension KeyboardMovementObserver {
114 let (duration, frame) = notification.keyboardMetaData()
115 if let keyboardFrame = frame {
116- let keyboardHeight = keyboardFrame.cgRectValue.size.height
117+ let keyboardHeight = heightOverlappingWindow(keyboardFrame.cgRectValue)
118 tag = UIResponder.current.reactViewTag
119 self.keyboardHeight = keyboardHeight
121diff --git a/ios/observers/movement/observer/KeyboardMovementObserver.swift b/ios/observers/movement/observer/KeyboardMovementObserver.swift
122index ae97d611a7f727ebbb0e17eabbb3294e1cc76a2f..2ea1d2ddd3fac6ad418d97c700ab885fe645951f 100644
123--- a/ios/observers/movement/observer/KeyboardMovementObserver.swift
124+++ b/ios/observers/movement/observer/KeyboardMovementObserver.swift
125@@ -37,6 +37,7 @@ public class KeyboardMovementObserver: NSObject {
126 // manual did events
127 var notification: Notification?
128 var keyboardDidTask: DispatchWorkItem?
129+ var floatingHideTask: DispatchWorkItem?
131 @objc public init(
132 handler: @escaping (NSString, NSNumber, NSNumber, NSNumber, NSNumber) -> Void,
133diff --git a/lib/commonjs/components/KeyboardChatScrollView/index.js b/lib/commonjs/components/KeyboardChatScrollView/index.js
134index 0b78ff38d8f0a2360632df3d9988c0c32bd56b99..9600d6c8ac857a3f56753f49b5a52e3eb830eaba 100644
135--- a/lib/commonjs/components/KeyboardChatScrollView/index.js
136+++ b/lib/commonjs/components/KeyboardChatScrollView/index.js
137@@ -28,9 +28,12 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
138 offset = 0,
139 extraContentPadding = ZERO_CONTENT_PADDING,
140 blankSpace = ZERO_BLANK_SPACE,
141+ adjustedInsetCompensation = 0,
142+ adjustedStartInsetCompensation = 0,
143 applyWorkaroundForContentInsetHitTestBug = false,
144 onLayout: onLayoutProp,
145 onContentSizeChange: onContentSizeChangeProp,
146+ onContentInsetChange,
147 onEndVisible,
148 ...rest
149 }, ref) => {
150@@ -54,6 +57,8 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
151 offset,
152 blankSpace,
153 extraContentPadding,
154+ adjustedInsetCompensation,
155+ adjustedStartInsetCompensation,
156 initialContentOffsetY: (_rest$contentOffset = rest.contentOffset) === null || _rest$contentOffset === void 0 ? void 0 : _rest$contentOffset.y
157 });
158 (0, _useExtraContentPadding.useExtraContentPadding)({
159@@ -61,6 +66,8 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
160 extraContentPadding,
161 keyboardPadding: padding,
162 blankSpace,
163+ adjustedInsetCompensation,
164+ adjustedStartInsetCompensation,
165 scroll,
166 layout,
167 size,
168@@ -72,7 +79,8 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
169 (0, _useFrozenPadding.useFrozenPadding)({
170 freeze: freezeSV,
171 offset,
172- padding
173+ padding,
174+ currentHeight
175 });
176 (0, _useEndVisible.useEndVisible)({
177 scroll,
178@@ -91,10 +99,26 @@ const KeyboardChatScrollView = /*#__PURE__*/(0, _react.forwardRef)(({
179 // a bug for you, please open an issue.
180 const totalPadding = (0, _reanimated.useDerivedValue)(() => Math.min(layout.value.height, Math.max(blankSpace.value, padding.value + extraContentPadding.value)));
182+ // iOS applies the destination contentInset and contentOffset together at
183+ // keyboard-animation start. Report the presentation height only while it is larger
184+ // (closing): a smaller one sends end-following short of the native end, so it bounces.
185+ const reportedPadding = (0, _reanimated.useDerivedValue)(() => _reactNative.Platform.OS === "ios" ? Math.max(totalPadding.value, Math.min(layout.value.height, Math.max(blankSpace.value, currentHeight.value + extraContentPadding.value))) : totalPadding.value);
186+
187+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
188+ // to the consumer - a virtualized list needs it in its own scroll math or
189+ // its end/maintain targets point at the under-the-keyboard resting offset.
190+ (0, _reanimated.useAnimatedReaction)(() => reportedPadding.value, (current, previous) => {
191+ if (onContentInsetChange && current !== previous) {
192+ (0, _reactNativeReanimated.runOnJS)(onContentInsetChange)({
193+ bottom: current
194+ });
195+ }
196+ }, [onContentInsetChange]);
197+
198 // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
199 // Apps that render into the unsafe area can supply a negative
200 // scrollIndicatorInsets adjustment at the application layer.
201- const indicatorPadding = (0, _reanimated.useDerivedValue)(() => padding.value + extraContentPadding.value);
202+ const indicatorPadding = (0, _reanimated.useDerivedValue)(() => padding.value);
203 const onLayout = (0, _react.useCallback)(e => {
204 onLayoutInternal(e);
205 onLayoutProp === null || onLayoutProp === void 0 || onLayoutProp(e);
206diff --git a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
207index 4d33b3fe426070cf312fc493ce902b2c24d853ea..6a787d3054ba09e90c54b615ab302df51a2888f7 100644
208--- a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
209+++ b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
210@@ -206,7 +206,7 @@ const clampedScrollTarget = (offsetBeforeScroll, keyboardHeight, contentHeight,
211 * ```
212 */
213 exports.clampedScrollTarget = clampedScrollTarget;
214-const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll) => {
215+const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll, startInsetCompensation = 0) => {
216 "worklet";
218 const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
219@@ -214,8 +214,9 @@ const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight,
220 const maxScroll = Math.max(contentHeight - layoutHeight, 0);
221 return Math.max(Math.min(relativeScroll - keyboardHeight, maxScroll), -paddingForMax);
222 }
223- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
224- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
225+ const minScroll = -startInsetCompensation;
226+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, minScroll);
227+ return Math.min(Math.max(keyboardHeight + relativeScroll, minScroll), maxScroll);
228 };
229 exports.computeIOSContentOffset = computeIOSContentOffset;
230 //# sourceMappingURL=helpers.js.map
231\ No newline at end of file
232diff --git a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
233index 8ac59042f670460fa822b1a36d971e4c0d5abe2f..480b60f7b55d7a4945bf163e5378311638c437fc 100644
234--- a/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
235+++ b/lib/commonjs/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
236@@ -32,7 +32,9 @@ function useChatKeyboard(scrollViewRef, options) {
237 freeze,
238 offset,
239 blankSpace,
240- extraContentPadding
241+ extraContentPadding,
242+ adjustedInsetCompensation,
243+ adjustedStartInsetCompensation
244 } = options;
245 const padding = (0, _reactNativeReanimated.useSharedValue)(0);
246 const currentHeight = (0, _reactNativeReanimated.useSharedValue)(0);
247@@ -67,6 +69,9 @@ function useChatKeyboard(scrollViewRef, options) {
248 prevAbsorption.value = padding.value;
249 }
250 const effective = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
251+ if (e.duration === 0) {
252+ currentHeight.value = effective;
253+ }
254 const atEnd = (0, _helpers.isScrollAtEnd)(scroll.value, layout.value.height, size.value.height, inverted);
256 // Scale minimum padding absorption by how much of it is visible.
257@@ -75,7 +80,7 @@ function useChatKeyboard(scrollViewRef, options) {
258 const visiblePadding = visibleFraction * blankSpace.value;
259 const minimumPaddingAbsorbed = Math.max(0, visiblePadding - extraContentPadding.value);
260 const scrollEffective = (0, _helpers.getScrollEffective)(effective, minimumPaddingAbsorbed);
261- const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value);
262+ const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value) + adjustedInsetCompensation;
264 // `onInteractive` owns the native scroll offset. When its final
265 // keyboardWillHide event arrives, consume the marker so this
266@@ -95,8 +100,8 @@ function useChatKeyboard(scrollViewRef, options) {
267 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
268 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
269 } else {
270- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
271- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
272+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
273+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
274 }
275 return;
276 }
277@@ -110,8 +115,8 @@ function useChatKeyboard(scrollViewRef, options) {
278 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
279 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
280 } else {
281- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
282- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
283+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
284+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
285 }
286 return;
287 }
288@@ -137,17 +142,25 @@ function useChatKeyboard(scrollViewRef, options) {
289 contentOffsetY.value = scroll.value;
290 return;
291 }
292- contentOffsetY.value = (0, _helpers.computeIOSContentOffset)(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding);
293+ contentOffsetY.value = (0, _helpers.computeIOSContentOffset)(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding, adjustedStartInsetCompensation);
294 },
295- onInteractive: () => {
296+ onMove: e => {
297 "worklet";
299- isInteractiveDismissal.value = true;
300+ if (freeze.value) {
301+ return;
302+ }
303+ currentHeight.value = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
304 },
305- onMove: () => {
306+ onInteractive: e => {
307 "worklet";
309- // iOS doesn't need per-frame updates (contentOffset handles it)
310+ isInteractiveDismissal.value = true;
311+
312+ if (freeze.value) {
313+ return;
314+ }
315+ currentHeight.value = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
316 },
317 onEnd: e => {
318 "worklet";
319@@ -156,9 +169,10 @@ function useChatKeyboard(scrollViewRef, options) {
320 return;
321 }
322 const effective = (0, _helpers.getEffectiveHeight)(e.height, targetKeyboardHeight.value, offset);
323+ currentHeight.value = effective;
324 padding.value = effective;
325 }
326- }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
327+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding, adjustedInsetCompensation, adjustedStartInsetCompensation]);
328 return {
329 padding,
330 currentHeight,
331diff --git a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
332index 1c2912e70a1a0c4a75ae8ec4cfbc4d7fa7bc6b83..eaf845042700207e4251b2fa66e5797b606f1fbb 100644
333--- a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
334+++ b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
335@@ -33,6 +33,8 @@ function useExtraContentPadding(options) {
336 extraContentPadding,
337 keyboardPadding,
338 blankSpace,
339+ adjustedInsetCompensation,
340+ adjustedStartInsetCompensation,
341 scroll,
342 layout,
343 size,
344@@ -74,8 +76,8 @@ function useExtraContentPadding(options) {
345 }
347 // Compute effective delta considering blankSpace floor
348- const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous);
349- const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current);
350+ const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous) + adjustedInsetCompensation;
351+ const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current) + adjustedInsetCompensation;
352 // Native scroll offsets are pixel-rounded. Feeding their fractions back
353 // into each animation step accumulates drift depending on frame timing.
354 // Round absolute totals before subtracting so the total movement stays
355@@ -120,14 +122,15 @@ function useExtraContentPadding(options) {
356 if (inverted) {
357 target = Math.max(base - effectiveDelta, -currentTotal);
358 } else {
359- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
360+ const minScroll = -adjustedStartInsetCompensation;
361+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
363- // Clamp at 0 as well: when the content is shorter than the viewport a
364- // shrinking padding makes `effectiveDelta` negative while `base` is
365- // already 0, so the target would go below the top of the content.
366- target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
367+ // Clamp at the top as well: when the content is shorter than the
368+ // viewport a shrinking padding makes `effectiveDelta` negative while
369+ // `base` is already at the top.
370+ target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
371 }
372 scrollToTarget(target);
373- }, [inverted, keyboardLiftBehavior]);
374+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
375 }
376 //# sourceMappingURL=index.js.map
377\ No newline at end of file
378diff --git a/lib/commonjs/components/KeyboardChatScrollView/useFrozenPadding/index.js b/lib/commonjs/components/KeyboardChatScrollView/useFrozenPadding/index.js
379index 444fef5eea3988b60cb62a6b4b42084ef0510fd9..3e684bf71d5e58659a8367733a7c2ee47cc05455 100644
380--- a/lib/commonjs/components/KeyboardChatScrollView/useFrozenPadding/index.js
381+++ b/lib/commonjs/components/KeyboardChatScrollView/useFrozenPadding/index.js
382@@ -30,7 +30,8 @@ var _helpers = require("../useChatKeyboard/helpers");
383 function useFrozenPadding({
384 freeze,
385 offset,
386- padding
387+ padding,
388+ currentHeight
389 }) {
390 const lastHeight = (0, _reactNativeReanimated.useSharedValue)(0);
391 const targetKeyboardHeight = (0, _reactNativeReanimated.useSharedValue)(0);
392@@ -56,7 +57,9 @@ function useFrozenPadding({
393 }, []);
394 (0, _reanimated.useAnimatedReaction)(() => freeze.value, (isFrozen, wasFrozen) => {
395 if (!isFrozen && wasFrozen === true) {
396- padding.value = (0, _helpers.getEffectiveHeight)(lastHeight.value, targetKeyboardHeight.value, offset);
397+ const effective = (0, _helpers.getEffectiveHeight)(lastHeight.value, targetKeyboardHeight.value, offset);
398+ padding.value = effective;
399+ currentHeight.value = effective;
400 }
401 }, [offset]);
402 }
403diff --git a/lib/commonjs/hooks/useKeyboardState/index.js b/lib/commonjs/hooks/useKeyboardState/index.js
404index a4b287006a47011a58c8a16f19b31a479087f44e..4084025d644c8555b269f9d496266e2cb3234024 100644
405--- a/lib/commonjs/hooks/useKeyboardState/index.js
406+++ b/lib/commonjs/hooks/useKeyboardState/index.js
407@@ -7,7 +7,7 @@ exports.useKeyboardState = useKeyboardState;
408 var _react = require("react");
409 var _bindings = require("../../bindings");
410 var _module = require("../../module");
411-const EVENTS = ["keyboardWillShow", "keyboardDidHide"];
412+const EVENTS = ["keyboardWillShow", "keyboardDidShow", "keyboardDidHide"];
413 const getLatestState = () => ({
414 ..._module.KeyboardController.state(),
415 isVisible: _module.KeyboardController.isVisible()
416diff --git a/lib/commonjs/module.js b/lib/commonjs/module.js
417index f27c5a095129cf60831088a73ce94d44f3ba52cd..3c2f7569510d0a56fd937b6e91a6adc0d5ff6f59 100644
418--- a/lib/commonjs/module.js
419+++ b/lib/commonjs/module.js
420@@ -22,6 +22,12 @@ _bindings.KeyboardEvents.addListener("keyboardWillShow", e => {
421 isClosed = false;
422 lastState = e;
423 });
424+// Android re-syncs an IME inset that changes without an animation with keyboardDidShow
425+// alone. Drop with kirillzyusko/react-native-keyboard-controller#1698.
426+_bindings.KeyboardEvents.addListener("keyboardDidShow", e => {
427+ isClosed = false;
428+ lastState = e;
429+});
430 const dismiss = async options => {
431 const keepFocus = (options === null || options === void 0 ? void 0 : options.keepFocus) ?? false;
432 const animated = (options === null || options === void 0 ? void 0 : options.animated) ?? true;
433diff --git a/lib/module/components/KeyboardChatScrollView/index.js b/lib/module/components/KeyboardChatScrollView/index.js
434index e0c83918d9569e2ff541e45d31460121c73ec225..724c62e2892f75f6bb53844b84c1ade1bf87c7ec 100644
435--- a/lib/module/components/KeyboardChatScrollView/index.js
436+++ b/lib/module/components/KeyboardChatScrollView/index.js
437@@ -1,9 +1,9 @@
438 function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
439 import React, { forwardRef, useCallback, useMemo } from "react";
440-import { StyleSheet } from "react-native";
441-import { makeMutable, useAnimatedRef } from "react-native-reanimated";
442+import { Platform, StyleSheet } from "react-native";
443+import { makeMutable, runOnJS, useAnimatedRef } from "react-native-reanimated";
444 import Reanimated from "react-native-reanimated";
445-import { useAnimatedStyle, useDerivedValue } from "../../reanimated";
446+import { useAnimatedReaction, useAnimatedStyle, useDerivedValue } from "../../reanimated";
447 import useCombinedRef from "../hooks/useCombinedRef";
448 import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
449 import { useChatKeyboard } from "./useChatKeyboard";
450@@ -21,9 +21,12 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
451 offset = 0,
452 extraContentPadding = ZERO_CONTENT_PADDING,
453 blankSpace = ZERO_BLANK_SPACE,
454+ adjustedInsetCompensation = 0,
455+ adjustedStartInsetCompensation = 0,
456 applyWorkaroundForContentInsetHitTestBug = false,
457 onLayout: onLayoutProp,
458 onContentSizeChange: onContentSizeChangeProp,
459+ onContentInsetChange,
460 onEndVisible,
461 ...rest
462 }, ref) => {
463@@ -47,6 +50,8 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
464 offset,
465 blankSpace,
466 extraContentPadding,
467+ adjustedInsetCompensation,
468+ adjustedStartInsetCompensation,
469 initialContentOffsetY: (_rest$contentOffset = rest.contentOffset) === null || _rest$contentOffset === void 0 ? void 0 : _rest$contentOffset.y
470 });
471 useExtraContentPadding({
472@@ -54,6 +59,8 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
473 extraContentPadding,
474 keyboardPadding: padding,
475 blankSpace,
476+ adjustedInsetCompensation,
477+ adjustedStartInsetCompensation,
478 scroll,
479 layout,
480 size,
481@@ -65,7 +72,8 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
482 useFrozenPadding({
483 freeze: freezeSV,
484 offset,
485- padding
486+ padding,
487+ currentHeight
488 });
489 useEndVisible({
490 scroll,
491@@ -84,10 +92,26 @@ const KeyboardChatScrollView = /*#__PURE__*/forwardRef(({
492 // a bug for you, please open an issue.
493 const totalPadding = useDerivedValue(() => Math.min(layout.value.height, Math.max(blankSpace.value, padding.value + extraContentPadding.value)));
495+ // iOS applies the destination contentInset and contentOffset together at
496+ // keyboard-animation start. Report the presentation height only while it is larger
497+ // (closing): a smaller one sends end-following short of the native end, so it bounces.
498+ const reportedPadding = useDerivedValue(() => Platform.OS === "ios" ? Math.max(totalPadding.value, Math.min(layout.value.height, Math.max(blankSpace.value, currentHeight.value + extraContentPadding.value))) : totalPadding.value);
499+
500+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
501+ // to the consumer - a virtualized list needs it in its own scroll math or
502+ // its end/maintain targets point at the under-the-keyboard resting offset.
503+ useAnimatedReaction(() => reportedPadding.value, (current, previous) => {
504+ if (onContentInsetChange && current !== previous) {
505+ runOnJS(onContentInsetChange)({
506+ bottom: current
507+ });
508+ }
509+ }, [onContentInsetChange]);
510+
511 // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
512 // Apps that render into the unsafe area can supply a negative
513 // scrollIndicatorInsets adjustment at the application layer.
514- const indicatorPadding = useDerivedValue(() => padding.value + extraContentPadding.value);
515+ const indicatorPadding = useDerivedValue(() => padding.value);
516 const onLayout = useCallback(e => {
517 onLayoutInternal(e);
518 onLayoutProp === null || onLayoutProp === void 0 || onLayoutProp(e);
519diff --git a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
520index 295e2219b560519b8d033968b5105d1da3e77315..2f7b87e6c68956f757db94a8197c1c61d1fafe28 100644
521--- a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
522+++ b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/helpers.js
523@@ -193,7 +193,7 @@ export const clampedScrollTarget = (offsetBeforeScroll, keyboardHeight, contentH
524 * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
525 * ```
526 */
527-export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll) => {
528+export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentHeight, layoutHeight, inverted, totalPaddingForMaxScroll, startInsetCompensation = 0) => {
529 "worklet";
531 const paddingForMax = totalPaddingForMaxScroll !== undefined ? totalPaddingForMaxScroll : keyboardHeight;
532@@ -201,7 +201,8 @@ export const computeIOSContentOffset = (relativeScroll, keyboardHeight, contentH
533 const maxScroll = Math.max(contentHeight - layoutHeight, 0);
534 return Math.max(Math.min(relativeScroll - keyboardHeight, maxScroll), -paddingForMax);
535 }
536- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
537- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
538+ const minScroll = -startInsetCompensation;
539+ const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, minScroll);
540+ return Math.min(Math.max(keyboardHeight + relativeScroll, minScroll), maxScroll);
541 };
542 //# sourceMappingURL=helpers.js.map
543\ No newline at end of file
544diff --git a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
545index 6a941e83d1c4a9c5cc57be4881ffe7121cd2b9a6..753893680fd20f207491f0c2dbca49da185e4373 100644
546--- a/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
547+++ b/lib/module/components/KeyboardChatScrollView/useChatKeyboard/index.ios.js
548@@ -25,7 +25,9 @@ function useChatKeyboard(scrollViewRef, options) {
549 freeze,
550 offset,
551 blankSpace,
552- extraContentPadding
553+ extraContentPadding,
554+ adjustedInsetCompensation,
555+ adjustedStartInsetCompensation
556 } = options;
557 const padding = useSharedValue(0);
558 const currentHeight = useSharedValue(0);
559@@ -60,6 +62,9 @@ function useChatKeyboard(scrollViewRef, options) {
560 prevAbsorption.value = padding.value;
561 }
562 const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
563+ if (e.duration === 0) {
564+ currentHeight.value = effective;
565+ }
566 const atEnd = isScrollAtEnd(scroll.value, layout.value.height, size.value.height, inverted);
568 // Scale minimum padding absorption by how much of it is visible.
569@@ -68,7 +73,7 @@ function useChatKeyboard(scrollViewRef, options) {
570 const visiblePadding = visibleFraction * blankSpace.value;
571 const minimumPaddingAbsorbed = Math.max(0, visiblePadding - extraContentPadding.value);
572 const scrollEffective = getScrollEffective(effective, minimumPaddingAbsorbed);
573- const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value);
574+ const actualTotalPadding = Math.max(blankSpace.value, effective + extraContentPadding.value) + adjustedInsetCompensation;
576 // `onInteractive` owns the native scroll offset. When its final
577 // keyboardWillHide event arrives, consume the marker so this
578@@ -88,8 +93,8 @@ function useChatKeyboard(scrollViewRef, options) {
579 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
580 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
581 } else {
582- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
583- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
584+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
585+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
586 }
587 return;
588 }
589@@ -103,8 +108,8 @@ function useChatKeyboard(scrollViewRef, options) {
590 const maxScroll = Math.max(size.value.height - layout.value.height, 0);
591 contentOffsetY.value = Math.max(-actualTotalPadding, Math.min(scroll.value, maxScroll));
592 } else {
593- const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, 0);
594- contentOffsetY.value = Math.max(0, Math.min(scroll.value, maxScroll));
595+ const maxScroll = Math.max(size.value.height - layout.value.height + actualTotalPadding, -adjustedStartInsetCompensation);
596+ contentOffsetY.value = Math.max(-adjustedStartInsetCompensation, Math.min(scroll.value, maxScroll));
597 }
598 return;
599 }
600@@ -130,17 +135,25 @@ function useChatKeyboard(scrollViewRef, options) {
601 contentOffsetY.value = scroll.value;
602 return;
603 }
604- contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding);
605+ contentOffsetY.value = computeIOSContentOffset(relativeScroll, scrollEffective, size.value.height, layout.value.height, inverted, actualTotalPadding, adjustedStartInsetCompensation);
606 },
607- onInteractive: () => {
608+ onMove: e => {
609 "worklet";
611- isInteractiveDismissal.value = true;
612+ if (freeze.value) {
613+ return;
614+ }
615+ currentHeight.value = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
616 },
617- onMove: () => {
618+ onInteractive: e => {
619 "worklet";
621- // iOS doesn't need per-frame updates (contentOffset handles it)
622+ isInteractiveDismissal.value = true;
623+
624+ if (freeze.value) {
625+ return;
626+ }
627+ currentHeight.value = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
628 },
629 onEnd: e => {
630 "worklet";
631@@ -149,9 +162,10 @@ function useChatKeyboard(scrollViewRef, options) {
632 return;
633 }
634 const effective = getEffectiveHeight(e.height, targetKeyboardHeight.value, offset);
635+ currentHeight.value = effective;
636 padding.value = effective;
637 }
638- }, [inverted, keyboardLiftBehavior, offset, extraContentPadding]);
639+ }, [inverted, keyboardLiftBehavior, offset, extraContentPadding, adjustedInsetCompensation, adjustedStartInsetCompensation]);
640 return {
641 padding,
642 currentHeight,
643diff --git a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
644index 458bced308670ec6bb30f8f5ef037ab841f4372b..9b7f1a5e9fa38928a07e7a462919105b76fe3155 100644
645--- a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
646+++ b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
647@@ -27,6 +27,8 @@ function useExtraContentPadding(options) {
648 extraContentPadding,
649 keyboardPadding,
650 blankSpace,
651+ adjustedInsetCompensation,
652+ adjustedStartInsetCompensation,
653 scroll,
654 layout,
655 size,
656@@ -68,8 +70,8 @@ function useExtraContentPadding(options) {
657 }
659 // Compute effective delta considering blankSpace floor
660- const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous);
661- const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current);
662+ const previousTotal = Math.max(blankSpace.value, keyboardPadding.value + previous) + adjustedInsetCompensation;
663+ const currentTotal = Math.max(blankSpace.value, keyboardPadding.value + current) + adjustedInsetCompensation;
664 // Native scroll offsets are pixel-rounded. Feeding their fractions back
665 // into each animation step accumulates drift depending on frame timing.
666 // Round absolute totals before subtracting so the total movement stays
667@@ -114,15 +116,16 @@ function useExtraContentPadding(options) {
668 if (inverted) {
669 target = Math.max(base - effectiveDelta, -currentTotal);
670 } else {
671- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
672+ const minScroll = -adjustedStartInsetCompensation;
673+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
675- // Clamp at 0 as well: when the content is shorter than the viewport a
676- // shrinking padding makes `effectiveDelta` negative while `base` is
677- // already 0, so the target would go below the top of the content.
678- target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
679+ // Clamp at the top as well: when the content is shorter than the
680+ // viewport a shrinking padding makes `effectiveDelta` negative while
681+ // `base` is already at the top.
682+ target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
683 }
684 scrollToTarget(target);
685- }, [inverted, keyboardLiftBehavior]);
686+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
687 }
688 export { useExtraContentPadding };
689 //# sourceMappingURL=index.js.map
690\ No newline at end of file
691diff --git a/lib/module/components/KeyboardChatScrollView/useFrozenPadding/index.js b/lib/module/components/KeyboardChatScrollView/useFrozenPadding/index.js
692index eddfd75913fef9111178771b4d5b4ba49864d217..d03dbd1e1fcbecb1866fb02547961a754eaf06e7 100644
693--- a/lib/module/components/KeyboardChatScrollView/useFrozenPadding/index.js
694+++ b/lib/module/components/KeyboardChatScrollView/useFrozenPadding/index.js
695@@ -24,7 +24,8 @@ import { getEffectiveHeight } from "../useChatKeyboard/helpers";
696 function useFrozenPadding({
697 freeze,
698 offset,
699- padding
700+ padding,
701+ currentHeight
702 }) {
703 const lastHeight = useSharedValue(0);
704 const targetKeyboardHeight = useSharedValue(0);
705@@ -50,7 +51,9 @@ function useFrozenPadding({
706 }, []);
707 useAnimatedReaction(() => freeze.value, (isFrozen, wasFrozen) => {
708 if (!isFrozen && wasFrozen === true) {
709- padding.value = getEffectiveHeight(lastHeight.value, targetKeyboardHeight.value, offset);
710+ const effective = getEffectiveHeight(lastHeight.value, targetKeyboardHeight.value, offset);
711+ padding.value = effective;
712+ currentHeight.value = effective;
713 }
714 }, [offset]);
715 }
716diff --git a/lib/module/hooks/useKeyboardState/index.js b/lib/module/hooks/useKeyboardState/index.js
717index 8da7c09fbb398253420d7bfcd9a85abdb981065b..31b1ff4370d8328a0569e559e3bbfa4b201f5a9d 100644
718--- a/lib/module/hooks/useKeyboardState/index.js
719+++ b/lib/module/hooks/useKeyboardState/index.js
720@@ -1,7 +1,7 @@
721 import { useEffect, useState } from "react";
722 import { KeyboardEvents } from "../../bindings";
723 import { KeyboardController } from "../../module";
724-const EVENTS = ["keyboardWillShow", "keyboardDidHide"];
725+const EVENTS = ["keyboardWillShow", "keyboardDidShow", "keyboardDidHide"];
726 const getLatestState = () => ({
727 ...KeyboardController.state(),
728 isVisible: KeyboardController.isVisible()
729diff --git a/lib/module/module.js b/lib/module/module.js
730index 01aad2effee498a8daec55e1d4644a5fbc723765..1140b706265d6c4295581c96b82b27bbf9e6d020 100644
731--- a/lib/module/module.js
732+++ b/lib/module/module.js
733@@ -16,6 +16,12 @@ KeyboardEvents.addListener("keyboardWillShow", e => {
734 isClosed = false;
735 lastState = e;
736 });
737+// Android re-syncs an IME inset that changes without an animation with keyboardDidShow
738+// alone. Drop with kirillzyusko/react-native-keyboard-controller#1698.
739+KeyboardEvents.addListener("keyboardDidShow", e => {
740+ isClosed = false;
741+ lastState = e;
742+});
743 const dismiss = async options => {
744 const keepFocus = (options === null || options === void 0 ? void 0 : options.keepFocus) ?? false;
745 const animated = (options === null || options === void 0 ? void 0 : options.animated) ?? true;
746diff --git a/lib/typescript/components/KeyboardChatScrollView/types.d.ts b/lib/typescript/components/KeyboardChatScrollView/types.d.ts
747index eba1514c2d94ae42c024da3882475567a8e8260b..6597d80df11f973ceb2f52c30ee0ece8bd812402 100644
748--- a/lib/typescript/components/KeyboardChatScrollView/types.d.ts
749+++ b/lib/typescript/components/KeyboardChatScrollView/types.d.ts
750@@ -88,6 +88,10 @@ export type KeyboardChatScrollViewProps = {
751 * Default is `undefined` (equivalent to `0` — no minimum floor).
752 */
753 blankSpace?: SharedValue<number>;
754+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
755+ adjustedInsetCompensation?: number;
756+ /** Leading inset UIKit adds outside raw contentInset. Offset math only. */
757+ adjustedStartInsetCompensation?: number;
758 /**
759 * Fires whenever the effective content inset changes — the static `contentInset`
760 * prop combined with the dynamic keyboard-driven padding.
761diff --git a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
762index 2b51cc4737b4a05b5396da31e67e54177f43c498..3acec1fbddee6227915590a6c8d449757cb4d7b2 100644
763--- a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
764+++ b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/helpers.d.ts
765@@ -129,4 +129,4 @@ export declare const clampedScrollTarget: (offsetBeforeScroll: number, keyboardH
766 * computeIOSContentOffset(100, 300, 1000, 800, false); // 400
767 * ```
768 */
769-export declare const computeIOSContentOffset: (relativeScroll: number, keyboardHeight: number, contentHeight: number, layoutHeight: number, inverted: boolean, totalPaddingForMaxScroll?: number) => number;
770+export declare const computeIOSContentOffset: (relativeScroll: number, keyboardHeight: number, contentHeight: number, layoutHeight: number, inverted: boolean, totalPaddingForMaxScroll?: number, startInsetCompensation?: number) => number;
771diff --git a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
772index 8d358bc7bb2c6e0a26e4c04810e371a7693edd84..911f3d90ce56de0f64a39b027d4fa147ba93d0cd 100644
773--- a/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
774+++ b/lib/typescript/components/KeyboardChatScrollView/useChatKeyboard/types.d.ts
775@@ -11,6 +11,10 @@ type UseChatKeyboardOptions = {
776 blankSpace: SharedValue<number>;
777 /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
778 extraContentPadding: SharedValue<number>;
779+ /** Safe-area extra beyond raw contentInset. Offset math only. */
780+ adjustedInsetCompensation: number;
781+ /** Leading inset UIKit adds beyond the raw contentInset. Offset math only. */
782+ adjustedStartInsetCompensation: number;
783 };
784 type UseChatKeyboardReturn = {
785 /** Extra scrollable space (= keyboard height). Used as contentInset on iOS, contentInsetBottom/contentInsetTop on Android. */
786diff --git a/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts b/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
787index ec73f70544a062fbecfc1d8be92d839d3e0bea6f..45b387446587fd3e611fa02a01534bb5d9fa6bbd 100644
788--- a/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
789+++ b/lib/typescript/components/KeyboardChatScrollView/useExtraContentPadding/index.d.ts
790@@ -8,6 +8,10 @@ type UseExtraContentPaddingOptions = {
791 keyboardPadding: SharedValue<number>;
792 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
793 blankSpace: SharedValue<number>;
794+ /** Safe-area extra beyond raw contentInset. Offset math only. */
795+ adjustedInsetCompensation: number;
796+ /** Leading inset UIKit adds beyond raw contentInset. Offset math only. */
797+ adjustedStartInsetCompensation: number;
798 /** Current vertical scroll offset. */
799 scroll: SharedValue<number>;
800 /** Visible viewport dimensions. */
801diff --git a/lib/typescript/components/KeyboardChatScrollView/useFrozenPadding/index.d.ts b/lib/typescript/components/KeyboardChatScrollView/useFrozenPadding/index.d.ts
802index 5c92b3850e21039eb7f11eb2944e2478c0ebab88..01d310135f5328f687087db09d9efb6a498e53d1 100644
803--- a/lib/typescript/components/KeyboardChatScrollView/useFrozenPadding/index.d.ts
804+++ b/lib/typescript/components/KeyboardChatScrollView/useFrozenPadding/index.d.ts
805@@ -6,6 +6,7 @@ type UseFrozenPaddingOptions = {
806 offset: number;
807 /** Keyboard-driven padding managed by `useChatKeyboard`. */
808 padding: SharedValue<number>;
809+ currentHeight: SharedValue<number>;
810 };
811 /**
812 * Hook that reconciles keyboard padding after a frozen interval.
813@@ -26,5 +27,5 @@ type UseFrozenPaddingOptions = {
814 * useFrozenPadding({ freeze, offset, padding });
815 * ```
816 */
817-declare function useFrozenPadding({ freeze, offset, padding, }: UseFrozenPaddingOptions): void;
818+declare function useFrozenPadding({ freeze, offset, padding, currentHeight, }: UseFrozenPaddingOptions): void;
819 export { useFrozenPadding };
820diff --git a/src/components/KeyboardChatScrollView/index.tsx b/src/components/KeyboardChatScrollView/index.tsx
821index 935bc71dabad6cd5c82bab77f64b5b6e1e5dc9b6..5306506e791c64e6c64abc91499c8974ac318301 100644
822--- a/src/components/KeyboardChatScrollView/index.tsx
823+++ b/src/components/KeyboardChatScrollView/index.tsx
824@@ -1,9 +1,13 @@
825 import React, { forwardRef, useCallback, useMemo } from "react";
826-import { StyleSheet } from "react-native";
827-import { makeMutable, useAnimatedRef } from "react-native-reanimated";
828+import { Platform, StyleSheet } from "react-native";
829+import { makeMutable, runOnJS, useAnimatedRef } from "react-native-reanimated";
830 import Reanimated from "react-native-reanimated";
832-import { useAnimatedStyle, useDerivedValue } from "../../reanimated";
833+import {
834+ useAnimatedReaction,
835+ useAnimatedStyle,
836+ useDerivedValue,
837+} from "../../reanimated";
838 import useCombinedRef from "../hooks/useCombinedRef";
839 import ScrollViewWithBottomPadding from "../ScrollViewWithBottomPadding";
841@@ -35,9 +39,12 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
842 offset = 0,
843 extraContentPadding = ZERO_CONTENT_PADDING,
844 blankSpace = ZERO_BLANK_SPACE,
845+ adjustedInsetCompensation = 0,
846+ adjustedStartInsetCompensation = 0,
847 applyWorkaroundForContentInsetHitTestBug = false,
848 onLayout: onLayoutProp,
849 onContentSizeChange: onContentSizeChangeProp,
850+ onContentInsetChange,
851 onEndVisible,
852 ...rest
853 },
854@@ -64,6 +71,8 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
855 offset,
856 blankSpace,
857 extraContentPadding,
858+ adjustedInsetCompensation,
859+ adjustedStartInsetCompensation,
860 initialContentOffsetY: rest.contentOffset?.y,
861 });
863@@ -72,6 +81,8 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
864 extraContentPadding,
865 keyboardPadding: padding,
866 blankSpace,
867+ adjustedInsetCompensation,
868+ adjustedStartInsetCompensation,
869 scroll,
870 layout,
871 size,
872@@ -85,6 +96,7 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
873 freeze: freezeSV,
874 offset,
875 padding,
876+ currentHeight,
877 });
879 useEndVisible({
880@@ -109,13 +121,40 @@ const KeyboardChatScrollView: React.ForwardRefExoticComponent<
881 ),
882 );
884- // Scroll indicator inset = keyboard + extraContentPadding (excludes blankSpace).
885- // Apps that render into the unsafe area can supply a negative
886- // scrollIndicatorInsets adjustment at the application layer.
887- const indicatorPadding = useDerivedValue(
888- () => padding.value + extraContentPadding.value,
889+ // iOS applies the destination contentInset and contentOffset together at
890+ // keyboard-animation start. Report the presentation height only while it is larger
891+ // (closing): a smaller one sends end-following short of the native end, so it bounces.
892+ const reportedPadding = useDerivedValue(() =>
893+ Platform.OS === "ios"
894+ ? Math.max(
895+ totalPadding.value,
896+ Math.min(
897+ layout.value.height,
898+ Math.max(blankSpace.value, currentHeight.value + extraContentPadding.value),
899+ ),
900+ )
901+ : totalPadding.value,
902 );
904+ // Mirror the effective bottom padding (keyboard + composer + blank floor)
905+ // to the consumer — a virtualized list needs it in its own scroll math or
906+ // its end/maintain targets point at the under-the-keyboard resting offset.
907+ useAnimatedReaction(
908+ () => reportedPadding.value,
909+ (current, previous) => {
910+ if (onContentInsetChange && current !== previous) {
911+ runOnJS(onContentInsetChange)({ bottom: current });
912+ }
913+ },
914+ [onContentInsetChange],
915+ );
916+
917+ // Scroll indicator inset = keyboard only (excludes extraContentPadding and
918+ // blankSpace): with a floating composer the indicator track should run the
919+ // full height of the scroll view, behind the composer, like iOS Messages.
920+ // The keyboard still lifts it so it never disappears under the keyboard.
921+ const indicatorPadding = useDerivedValue(() => padding.value);
922+
923 const onLayout = useCallback(
924 (e: LayoutChangeEvent) => {
925 onLayoutInternal(e);
926diff --git a/src/components/KeyboardChatScrollView/types.ts b/src/components/KeyboardChatScrollView/types.ts
927index b7c98c8ede80f690c8c9ad60263efe3ebd5b73df..e1012a80d59ff172396ff17550cb8402d5ba5673 100644
928--- a/src/components/KeyboardChatScrollView/types.ts
929+++ b/src/components/KeyboardChatScrollView/types.ts
930@@ -93,6 +93,17 @@ export type KeyboardChatScrollViewProps = {
931 * Default is `undefined` (equivalent to `0` — no minimum floor).
932 */
933 blankSpace?: SharedValue<number>;
934+ /**
935+ * Extra bottom inset UIKit adds on top of the raw `contentInset` this
936+ * component writes (e.g. the home-indicator safe area under
937+ * `contentInsetAdjustmentBehavior="automatic"`). Used ONLY in scroll-offset
938+ * math (max scroll / end pinning) — never written into `contentInset`.
939+ *
940+ * Default is `0`.
941+ */
942+ adjustedInsetCompensation?: number;
943+ /** Leading inset UIKit adds outside raw contentInset. Offset math only. */
944+ adjustedStartInsetCompensation?: number;
945 /**
946 * Fires whenever the effective content inset changes — the static `contentInset`
947 * prop combined with the dynamic keyboard-driven padding.
948diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
949index 37eacd10857cd70c51b3468c4b466e4959d0a415..3d77ab27c614f44b64da8270823942cb670b097b 100644
950--- a/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
951+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/helpers.ts
952@@ -245,6 +245,7 @@ export const computeIOSContentOffset = (
953 layoutHeight: number,
954 inverted: boolean,
955 totalPaddingForMaxScroll?: number,
956+ startInsetCompensation: number = 0,
957 ): number => {
958 "worklet";
960@@ -262,7 +263,14 @@ export const computeIOSContentOffset = (
961 );
962 }
964- const maxScroll = Math.max(contentHeight - layoutHeight + paddingForMax, 0);
965+ const minScroll = -startInsetCompensation;
966+ const maxScroll = Math.max(
967+ contentHeight - layoutHeight + paddingForMax,
968+ minScroll,
969+ );
971- return Math.min(Math.max(keyboardHeight + relativeScroll, 0), maxScroll);
972+ return Math.min(
973+ Math.max(keyboardHeight + relativeScroll, minScroll),
974+ maxScroll,
975+ );
976 };
977diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
978index f67fc0d1706bc7ab9169da533514a961799a5551..a599edb77c094574c57adcb217d8404e3cb63d7d 100644
979--- a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
980+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ios.ts
981@@ -43,6 +43,8 @@ function useChatKeyboard(
982 offset,
983 blankSpace,
984 extraContentPadding,
985+ adjustedInsetCompensation,
986+ adjustedStartInsetCompensation,
987 } = options;
989 const padding = useSharedValue(0);
990@@ -90,6 +92,10 @@ function useChatKeyboard(
991 offset,
992 );
994+ if (e.duration === 0) {
995+ currentHeight.value = effective;
996+ }
997+
998 const atEnd = isScrollAtEnd(
999 scroll.value,
1000 layout.value.height,
1001@@ -115,10 +121,12 @@ function useChatKeyboard(
1002 effective,
1003 minimumPaddingAbsorbed,
1004 );
1005- const actualTotalPadding = Math.max(
1006- blankSpace.value,
1007- effective + extraContentPadding.value,
1008- );
1009+ // UIKit adds adjustedInsetCompensation (safe area) on top of the raw
1010+ // inset; include it here so end/max-scroll targets match the real
1011+ // resting offsets.
1012+ const actualTotalPadding =
1013+ Math.max(blankSpace.value, effective + extraContentPadding.value) +
1014+ adjustedInsetCompensation;
1016 // `onInteractive` owns the native scroll offset. When its final
1017 // keyboardWillHide event arrives, consume the marker so this
1018@@ -152,11 +160,11 @@ function useChatKeyboard(
1019 } else {
1020 const maxScroll = Math.max(
1021 size.value.height - layout.value.height + actualTotalPadding,
1022- 0,
1023+ -adjustedStartInsetCompensation,
1024 );
1026 contentOffsetY.value = Math.max(
1027- 0,
1028+ -adjustedStartInsetCompensation,
1029 Math.min(scroll.value, maxScroll),
1030 );
1031 }
1032@@ -187,11 +195,11 @@ function useChatKeyboard(
1033 } else {
1034 const maxScroll = Math.max(
1035 size.value.height - layout.value.height + actualTotalPadding,
1036- 0,
1037+ -adjustedStartInsetCompensation,
1038 );
1040 contentOffsetY.value = Math.max(
1041- 0,
1042+ -adjustedStartInsetCompensation,
1043 Math.min(scroll.value, maxScroll),
1044 );
1045 }
1046@@ -241,17 +249,36 @@ function useChatKeyboard(
1047 layout.value.height,
1048 inverted,
1049 actualTotalPadding,
1050+ adjustedStartInsetCompensation,
1051 );
1052 },
1053- onInteractive: () => {
1054+ onMove: (e) => {
1055 "worklet";
1057- isInteractiveDismissal.value = true;
1058+ if (freeze.value) {
1059+ return;
1060+ }
1061+
1062+ currentHeight.value = getEffectiveHeight(
1063+ e.height,
1064+ targetKeyboardHeight.value,
1065+ offset,
1066+ );
1067 },
1068- onMove: () => {
1069+ onInteractive: (e) => {
1070 "worklet";
1072- // iOS doesn't need per-frame updates (contentOffset handles it)
1073+ isInteractiveDismissal.value = true;
1074+
1075+ if (freeze.value) {
1076+ return;
1077+ }
1078+
1079+ currentHeight.value = getEffectiveHeight(
1080+ e.height,
1081+ targetKeyboardHeight.value,
1082+ offset,
1083+ );
1084 },
1085 onEnd: (e) => {
1086 "worklet";
1087@@ -266,10 +293,18 @@ function useChatKeyboard(
1088 offset,
1089 );
1091+ currentHeight.value = effective;
1092 padding.value = effective;
1093 },
1094 },
1095- [inverted, keyboardLiftBehavior, offset, extraContentPadding],
1096+ [
1097+ inverted,
1098+ keyboardLiftBehavior,
1099+ offset,
1100+ extraContentPadding,
1101+ adjustedInsetCompensation,
1102+ adjustedStartInsetCompensation,
1103+ ],
1104 );
1106 return {
1107diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
1108index f89b7c81f4ac0e85e98b790c75309b7203be1fb2..02e0e196f2f6c3222317429716e50da487ac45e3 100644
1109--- a/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
1110+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/types.ts
1111@@ -13,6 +13,10 @@ type UseChatKeyboardOptions = {
1112 blankSpace: SharedValue<number>;
1113 /** Extra content padding shared value — needed on iOS to correctly clamp contentOffset. */
1114 extraContentPadding: SharedValue<number>;
1115+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
1116+ adjustedInsetCompensation: number;
1117+ /** Leading inset UIKit adds beyond the raw contentInset. Offset math only. */
1118+ adjustedStartInsetCompensation: number;
1119 };
1121 type UseChatKeyboardReturn = {
1122diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
1123index 78fe7cf88b110c955a36d8df2ee5b90c088d4228..98719c1a320c474fc45a846d8ea8b16a16c4ab9d 100644
1124--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
1125+++ b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
1126@@ -18,6 +18,10 @@ type UseExtraContentPaddingOptions = {
1127 keyboardPadding: SharedValue<number>;
1128 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
1129 blankSpace: SharedValue<number>;
1130+ /** Extra bottom inset UIKit adds beyond the raw contentInset (safe area). Offset math only. */
1131+ adjustedInsetCompensation: number;
1132+ /** Leading inset UIKit adds beyond raw contentInset. Offset math only. */
1133+ adjustedStartInsetCompensation: number;
1134 /** Current vertical scroll offset. */
1135 scroll: SharedValue<number>;
1136 /** Visible viewport dimensions. */
1137@@ -53,6 +57,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
1138 extraContentPadding,
1139 keyboardPadding,
1140 blankSpace,
1141+ adjustedInsetCompensation,
1142+ adjustedStartInsetCompensation,
1143 scroll,
1144 layout,
1145 size,
1146@@ -104,14 +110,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
1147 }
1149 // Compute effective delta considering blankSpace floor
1150- const previousTotal = Math.max(
1151- blankSpace.value,
1152- keyboardPadding.value + previous,
1153- );
1154- const currentTotal = Math.max(
1155- blankSpace.value,
1156- keyboardPadding.value + current,
1157- );
1158+ const previousTotal =
1159+ Math.max(blankSpace.value, keyboardPadding.value + previous) +
1160+ adjustedInsetCompensation;
1161+ const currentTotal =
1162+ Math.max(blankSpace.value, keyboardPadding.value + current) +
1163+ adjustedInsetCompensation;
1164 // Native scroll offsets are pixel-rounded. Feeding their fractions back
1165 // into each animation step accumulates drift depending on frame timing.
1166 // Round absolute totals before subtracting so the total movement stays
1167@@ -175,20 +179,26 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
1168 if (inverted) {
1169 target = Math.max(base - effectiveDelta, -currentTotal);
1170 } else {
1171+ const minScroll = -adjustedStartInsetCompensation;
1172 const maxScroll = Math.max(
1173 size.value.height - layout.value.height + currentTotal,
1174- 0,
1175+ minScroll,
1176 );
1178- // Clamp at 0 as well: when the content is shorter than the viewport a
1179- // shrinking padding makes `effectiveDelta` negative while `base` is
1180- // already 0, so the target would go below the top of the content.
1181- target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
1182+ // Clamp at the top as well: when the content is shorter than the
1183+ // viewport a shrinking padding makes `effectiveDelta` negative while
1184+ // `base` is already at the top.
1185+ target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
1186 }
1188 scrollToTarget(target);
1189 },
1190- [inverted, keyboardLiftBehavior],
1191+ [
1192+ inverted,
1193+ keyboardLiftBehavior,
1194+ adjustedInsetCompensation,
1195+ adjustedStartInsetCompensation,
1196+ ],
1197 );
1198 }
1200diff --git a/src/components/KeyboardChatScrollView/useFrozenPadding/index.ts b/src/components/KeyboardChatScrollView/useFrozenPadding/index.ts
1201index 00b01bf2e8c8e948c15e1b89318bb82fef2c5f3f..26c4560230921074aa8ce31fad4615e5188e26c1 100644
1202--- a/src/components/KeyboardChatScrollView/useFrozenPadding/index.ts
1203+++ b/src/components/KeyboardChatScrollView/useFrozenPadding/index.ts
1204@@ -13,6 +13,8 @@ type UseFrozenPaddingOptions = {
1205 offset: number;
1206 /** Keyboard-driven padding managed by `useChatKeyboard`. */
1207 padding: SharedValue<number>;
1208+ /** Presentation keyboard height managed by `useChatKeyboard`. */
1209+ currentHeight: SharedValue<number>;
1210 };
1212 /**
1213@@ -38,6 +40,7 @@ function useFrozenPadding({
1214 freeze,
1215 offset,
1216 padding,
1217+ currentHeight,
1218 }: UseFrozenPaddingOptions): void {
1219 const lastHeight = useSharedValue(0);
1220 const targetKeyboardHeight = useSharedValue(0);
1221@@ -70,11 +73,14 @@ function useFrozenPadding({
1222 () => freeze.value,
1223 (isFrozen, wasFrozen) => {
1224 if (!isFrozen && wasFrozen === true) {
1225- padding.value = getEffectiveHeight(
1226+ const effective = getEffectiveHeight(
1227 lastHeight.value,
1228 targetKeyboardHeight.value,
1229 offset,
1230 );
1231+
1232+ padding.value = effective;
1233+ currentHeight.value = effective;
1234 }
1235 },
1236 [offset],
1237diff --git a/src/hooks/useKeyboardState/index.ts b/src/hooks/useKeyboardState/index.ts
1238index e5fe38dd8e7b8370bfb575296259933094857ca5..d0b98f60a6d7ad7f72ebd70b22e1ce6b7fb56874 100644
1239--- a/src/hooks/useKeyboardState/index.ts
1240+++ b/src/hooks/useKeyboardState/index.ts
1241@@ -5,7 +5,7 @@ import { KeyboardController } from "../../module";
1243 import type { IKeyboardState } from "../../types";
1245-const EVENTS = ["keyboardWillShow", "keyboardDidHide"] as const;
1246+const EVENTS = ["keyboardWillShow", "keyboardDidShow", "keyboardDidHide"] as const;
1248 const getLatestState = () => ({
1249 ...KeyboardController.state(),
1250diff --git a/src/module.ts b/src/module.ts
1251index f74941914c9ecebbd0a6c2ba55c5436378de79d4..b7223cff162d18be11f8de248a7bb8f32e694658 100644
1252--- a/src/module.ts
1253+++ b/src/module.ts
1254@@ -26,6 +26,13 @@ KeyboardEvents.addListener("keyboardWillShow", (e) => {
1255 lastState = e;
1256 });
1258+// Android re-syncs an IME inset that changes without an animation with keyboardDidShow
1259+// alone. Drop with kirillzyusko/react-native-keyboard-controller#1698.
1260+KeyboardEvents.addListener("keyboardDidShow", (e) => {
1261+ isClosed = false;
1262+ lastState = e;
1263+});
1264+
1265 const dismiss = async (options?: Partial<DismissOptions>): Promise<void> => {
1266 const keepFocus = options?.keepFocus ?? false;
1267 const animated = options?.animated ?? true;