guard scrollTo against detached ref in chat keyboard onMove

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Samuel Newman
2026-07-08 13:42:27 +03:00
parent ea3d6827c7
commit b70576daa8
2 changed files with 26 additions and 3 deletions
@@ -1,3 +1,26 @@
diff --git a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts
index 48178d9246ab94d701983ac20473983eb746d1a6..451d38e6e20646c32795db3be28fbea57de1d12f 100644
--- a/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts
+++ b/src/components/KeyboardChatScrollView/useChatKeyboard/index.ts
@@ -172,6 +172,18 @@ function useChatKeyboard(
currentHeight.value = e.height;
+ if (scrollViewRef() == null) {
+ // The scroll view can be detached or not yet attached while a
+ // keyboard animation is running (e.g. the chat list re-creating its
+ // scroll component mid-animation). Every branch below eventually
+ // calls scrollTo (directly or via clampScrollIfNeeded); on Paper
+ // reanimated's scrollTo would hand the null ref to the native
+ // _scrollToPaper HostFunction, which throws "Value is null, expected
+ // a number" and crashes in release builds. currentHeight is kept up
+ // to date above so the animated style keeps committing.
+ return;
+ }
+
if (inverted) {
// Skip post-interactive snap-back (duration === -1)
if (e.duration === -1) {
diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
index 0f6d7c67a307885310ab184fdf9e7a5c7b296825..1a01093e7909973cef5268f999158df389e77634 100644
--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts