@@ -99,6 +99,7 @@ import {
9999 KeyboardController ,
100100 KeyboardStickyView ,
101101 useKeyboardState ,
102+ useReanimatedKeyboardAnimation ,
102103} from "react-native-keyboard-controller" ;
103104import Animated , {
104105 Easing ,
@@ -956,10 +957,8 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
956957 ) ;
957958 const userInputCollapsed =
958959 activeUserInputRequestId !== null && collapsedUserInputRequestId === activeUserInputRequestId ;
959- // The card's height RESERVES keyboard space at all times instead of tracking the keyboard:
960- // transforms (the sticky translation) apply same-frame on the UI thread while layout props lag
961- // a Yoga pass behind, so any height that follows the keyboard flashes the card over the nav
962- // header on the way up.
960+ // A height React sets from keyboard state lags the sticky translation by a Yoga pass and
961+ // flashes over the nav header on the way up, so the usage panel reserves the keyboard instead.
963962 const [ lastKnownKeyboardHeight , setLastKnownKeyboardHeight ] = useState ( 0 ) ;
964963 useEffect ( ( ) => {
965964 if ( liveKeyboardHeight > 0 && liveKeyboardHeight !== lastKnownKeyboardHeight ) {
@@ -968,12 +967,11 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
968967 } , [ lastKnownKeyboardHeight , liveKeyboardHeight ] ) ;
969968 const reservedKeyboardHeight =
970969 lastKnownKeyboardHeight > 0 ? lastKnownKeyboardHeight : ESTIMATED_KEYBOARD_HEIGHT ;
971- const pendingUserInputMaxHeight = derivePendingUserInputMaxHeight ( {
972- windowHeight,
973- keyboardHeight : reservedKeyboardHeight ,
974- navigationHeaderHeight,
975- composerOverlapHeight : composerBottomInset ,
976- } ) ;
970+ // Waiting for a visibility render misses the first keyboard frames.
971+ const keyboardStickyEnabled =
972+ Platform . OS === "ios"
973+ ? deviceType !== "duo-unfolded" || ( composerOwnsKeyboard && ! sidebarSearchActive )
974+ : ! keyboardStateSuspect ;
977975 const estimatedOverlayHeight = composerOverlapHeight ;
978976 // The overlay's measured height includes the home-indicator inset (the
979977 // composer pads it), but contentInsetAdjustmentBehavior="automatic" makes
@@ -1000,6 +998,18 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
1000998 setScreenHeight ( event . nativeEvent . layout . height ) ;
1001999 } , [ ] ) ;
10021000 const screenAreaHeight = screenHeight ?? windowHeight ;
1001+ // The question card reads the keyboard frame on the UI thread, in the same frame the sticky
1002+ // view translates, so it gets the full height while the keyboard is closed and never crosses
1003+ // the header while the keyboard moves.
1004+ const { height : keyboardTranslation } = useReanimatedKeyboardAnimation ( ) ;
1005+ const pendingUserInputMaxHeight = useDerivedValue ( ( ) =>
1006+ derivePendingUserInputMaxHeight ( {
1007+ windowHeight : screenAreaHeight ,
1008+ keyboardHeight : keyboardStickyEnabled ? - keyboardTranslation . value : 0 ,
1009+ navigationHeaderHeight,
1010+ composerOverlapHeight : composerBottomInset ,
1011+ } ) ,
1012+ ) ;
10031013 // The usage panel stacks with the composer and any approval card, so it gets
10041014 // whatever room they leave below the header. Measured only while it is open
10051015 // so typing in the composer does not re-render the screen.
@@ -1024,9 +1034,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
10241034 usageLimitsLayout . overlay > 0
10251035 ? usageLimitsLayout . overlay - usageLimitsLayout . panel
10261036 : composerOverlapHeight ;
1027- // The keyboard is reserved even while closed, like the question card, so the
1028- // panel never grows over the header while the keyboard animates. The floor
1029- // keeps the close row on screen when the stack below leaves no room at all.
1037+ // The floor keeps the close row on screen when the stack below leaves no room at all.
10301038 const usageLimitsMaxHeight = Math . max (
10311039 USAGE_LIMITS_PANEL_MIN_HEIGHT ,
10321040 Math . min (
@@ -1536,12 +1544,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
15361544
15371545 { showContent ? (
15381546 < KeyboardStickyView
1539- // Waiting for a visibility render misses the first keyboard frames.
1540- enabled = {
1541- Platform . OS === "ios"
1542- ? deviceType !== "duo-unfolded" || ( composerOwnsKeyboard && ! sidebarSearchActive )
1543- : ! keyboardStateSuspect
1544- }
1547+ enabled = { keyboardStickyEnabled }
15451548 pointerEvents = "box-none"
15461549 style = { { position : "absolute" , bottom : 0 , left : 0 , right : 0 , top : 0 } }
15471550 offset = { { closed : 0 , opened : composerKeyboardOffset } }
0 commit comments