Skip to content

Commit dc52893

Browse files
ThallesPclaudejuliusmarminge
authored
fix(mobile): the Android composer no longer lags the keyboard or drops under the nav bar (pingdotgg#19980)
Co-authored-by: Claude Opus 5.5 <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
1 parent da26f1e commit dc52893

2 files changed

Lines changed: 13 additions & 14 deletions

File tree

‎apps/mobile/src/features/threads/ThreadDetailScreen.tsx‎

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -493,16 +493,13 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
493493
const [anchorMessageId, setAnchorMessageId] = useState<MessageId | null>(null);
494494
const [submittedMessageId, setSubmittedMessageId] = useState<MessageId | null>(null);
495495
const [endFollowEnabled, setEndFollowEnabled] = useState(true);
496-
// Android keys the safe-area padding on keyboard visibility (#5988): the back gesture closes
497-
// the keyboard while the editor stays focused, and a focus-keyed inset would leave the toolbar
498-
// under the gesture bar. iOS must NOT use visibility — it only flips on keyboardDidHide, after
499-
// the hide animation, so the composer would ride down flush to the screen edge and then snap up
500-
// into the inset.
501-
const composerBottomInset = (
502-
Platform.OS === "android" ? isKeyboardVisible : composerExpanded || composerFocused
503-
)
504-
? 0
505-
: Math.max(insets.bottom, 12);
496+
// Android Back hides the keyboard without blurring. Keep its safe-area padding
497+
// fixed through the animation and cancel it with matching composer/list offsets.
498+
const composerBottomInset =
499+
Platform.OS === "ios" && (composerExpanded || composerFocused)
500+
? 0
501+
: Math.max(insets.bottom, 12);
502+
const composerKeyboardOffset = Platform.OS === "android" ? composerBottomInset : 0;
506503
const contentPresentationKind = props.contentPresentation.kind;
507504
const realThreadSyncLabel = (() => {
508505
switch (props.threadSyncStatus) {
@@ -1145,6 +1142,7 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
11451142
anchorMessageId={anchorMessageId}
11461143
submittedMessageId={submittedMessageId}
11471144
contentInsetEndAdjustment={combinedContentInsetEndAdjustment}
1145+
keyboardOffset={composerKeyboardOffset}
11481146
contentTopInset={0}
11491147
contentBottomInset={
11501148
estimatedOverlayHeight +
@@ -1180,12 +1178,11 @@ export const ThreadDetailScreen = function ThreadDetailScreen(props: ThreadDetai
11801178

11811179
{showContent ? (
11821180
<KeyboardStickyView
1183-
// iOS emits a native animated height target on both will-show and
1184-
// will-hide, so stay subscribed for the full transition.
1185-
enabled={Platform.OS === "ios" || (isKeyboardVisible && !keyboardStateSuspect)}
1181+
// Waiting for a visibility render misses the first keyboard frames.
1182+
enabled={Platform.OS === "ios" || !keyboardStateSuspect}
11861183
pointerEvents="box-none"
11871184
style={{ position: "absolute", bottom: 0, left: 0, right: 0, top: 0 }}
1188-
offset={{ closed: 0, opened: 0 }}
1185+
offset={{ closed: 0, opened: composerKeyboardOffset }}
11891186
>
11901187
<ComposerPopoverHost hidden={composerSlotHidden} popoverHeight={composerPopoverHeight}>
11911188
{/* The fixed sticky host gives this bottom-anchored child a stable

‎apps/mobile/src/features/threads/ThreadFeed.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ export interface ThreadFeedProps {
304304
readonly anchorMessageId: MessageId | null;
305305
readonly submittedMessageId: MessageId | null;
306306
readonly contentInsetEndAdjustment: SharedValue<number>;
307+
readonly keyboardOffset: number;
307308
readonly contentTopInset?: number;
308309
readonly contentBottomInset?: number;
309310
readonly historyControls?: ThreadFeedHistoryControls;
@@ -2468,6 +2469,7 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
24682469
// content rest below the transparent header rather than at frame top.
24692470
contentInsetStartAdjustment={usesNativeAutomaticInsets ? anchorTopInset : 0}
24702471
contentInsetEndAdjustment={props.contentInsetEndAdjustment}
2472+
keyboardOffset={props.keyboardOffset}
24712473
// UIKit's automatic behavior adds the safe-area bottom on top of the
24722474
// raw contentInset the keyboard integration writes. The detail screen
24732475
// under-reports the composer inset by this amount (see

0 commit comments

Comments
 (0)