fix(mobile): land the first thread open above the composer on Android (#5585)
Co-authored-by: Claude Fable 5 <[email protected]> Co-authored-by: codex <[email protected]> Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
3 files changed
+60
-5
No files matched your search
@@ -76,7 +76,11 @@ import {
|
||||
} from "../review/nativeReviewDiffAdapter";
|
||||
import { buildReviewParsedDiff } from "../review/reviewModel";
|
||||
import { cn } from "../../lib/cn";
|
||||
import { deriveCenteredContentHorizontalPadding, type LayoutVariant } from "../../lib/layout";
|
||||
import {
|
||||
deriveCenteredContentHorizontalPadding,
|
||||
deriveThreadFeedInitialContentInset,
|
||||
type LayoutVariant,
|
||||
} from "../../lib/layout";
|
||||
import {
|
||||
resolveMarkdownFontSizes,
|
||||
resolveNativeMarkdownTypography,
|
||||
@@ -1555,6 +1559,11 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
const bottomContentInset = props.contentBottomInset ?? 18;
|
||||
const usesNativeAutomaticInsets =
|
||||
props.usesAutomaticContentInsets === true && Platform.OS === "ios";
|
||||
const initialContentInset = deriveThreadFeedInitialContentInset({
|
||||
platform: Platform.OS,
|
||||
usesNativeAutomaticInsets,
|
||||
bottomContentInset,
|
||||
});
|
||||
// With automatic insets the header inset lives in UIKit's adjustedContentInset,
|
||||
// which LegendList's JS anchoring math cannot see — it measures the anchored
|
||||
// end space from the scroll view's frame top. Fold the header height back into
|
||||
@@ -1794,10 +1803,10 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
// The empty↔filled key below remounts the list, which resets its imperative
|
||||
// content-inset override — and useKeyboardChatComposerInset (mounted above
|
||||
// the remount boundary) deduplicates by height, so it never re-reports the
|
||||
// composer inset to the fresh instance. Without this, the remounted list's
|
||||
// initial scroll-to-end computes with a zero end inset and rests one
|
||||
// composer-height short of the end. Layout effect: it must land before the
|
||||
// list's first positioning tick or the one-shot initial scroll misses it.
|
||||
// composer inset to the fresh instance. Re-report the measured overlay height
|
||||
// (composer plus any pending approval / user-input card) so the remounted
|
||||
// list's scroll math gets the true value; on Android the declarative
|
||||
// contentInset floor below covers the window before this effect lands.
|
||||
const listMountKey = `${feedThreadKey}:${props.feed.length === 0 ? "empty" : "filled"}`;
|
||||
useLayoutEffect(() => {
|
||||
const bottom = props.contentInsetEndAdjustment.value;
|
||||
@@ -2104,6 +2113,17 @@ export const ThreadFeed = memo(function ThreadFeed(props: ThreadFeedProps) {
|
||||
// ThreadDetailScreen); this tells LegendList's scroll math about the
|
||||
// extra so programmatic end scrolls land at the true resting offset.
|
||||
contentInsetEndStaticAdjustment={usesNativeAutomaticInsets ? insets.bottom : 0}
|
||||
// Android: the composer overlay only exists as the keyboard
|
||||
// integration's animated bottom padding, which the list's scroll
|
||||
// math cannot see until the inset reports above land — and those
|
||||
// arrive via runOnJS, racing the remounted list's one-shot initial
|
||||
// scroll-at-end. Seed the estimated overlay height as a declarative
|
||||
// contentInset floor: LegendList consumes it in JS math only
|
||||
// (Android's ScrollView has no native contentInset prop) and the
|
||||
// first reported override REPLACES it instead of adding to it.
|
||||
// Not on iOS: there the prop would reach UIKit and inset natively
|
||||
// on top of the animated padding.
|
||||
{...(initialContentInset ? { contentInset: initialContentInset } : {})}
|
||||
// The keyboard integration's offset math (end pinning, max scroll)
|
||||
// must add the same UIKit-added extra, or its keyboard-open end
|
||||
// targets land one safe-area short of the true resting offset.
|
||||
|
||||
@@ -7,11 +7,34 @@ import {
|
||||
deriveFileInspectorPaneLayout,
|
||||
deriveLayout,
|
||||
deriveStableFormSheetDetent,
|
||||
deriveThreadFeedInitialContentInset,
|
||||
deriveWorkspacePaneLayout,
|
||||
SPLIT_LAYOUT_MIN_HEIGHT,
|
||||
SPLIT_LAYOUT_MIN_WIDTH,
|
||||
} from "./layout";
|
||||
|
||||
describe("deriveThreadFeedInitialContentInset", () => {
|
||||
it("seeds Android scroll math with the composer overlay estimate", () => {
|
||||
expect(
|
||||
deriveThreadFeedInitialContentInset({
|
||||
platform: "android",
|
||||
usesNativeAutomaticInsets: false,
|
||||
bottomContentInset: 174,
|
||||
}),
|
||||
).toEqual({ bottom: 174 });
|
||||
});
|
||||
|
||||
it("does not double native iOS insets", () => {
|
||||
expect(
|
||||
deriveThreadFeedInitialContentInset({
|
||||
platform: "ios",
|
||||
usesNativeAutomaticInsets: true,
|
||||
bottomContentInset: 174,
|
||||
}),
|
||||
).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe("resizable pane constraints", () => {
|
||||
it("keeps a preferred sidebar width across large windows and clamps it in a narrow split view", () => {
|
||||
expect(constrainPrimarySidebarWidth(430, 1_366)).toBe(430);
|
||||
|
||||
@@ -52,6 +52,18 @@ export interface FileInspectorPaneLayout {
|
||||
readonly width: number | null;
|
||||
}
|
||||
|
||||
export function deriveThreadFeedInitialContentInset(input: {
|
||||
readonly platform: string;
|
||||
readonly usesNativeAutomaticInsets: boolean;
|
||||
readonly bottomContentInset: number;
|
||||
}): { readonly bottom: number } | undefined {
|
||||
if (input.platform !== "android" || input.usesNativeAutomaticInsets) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return { bottom: Math.max(0, input.bottomContentInset) };
|
||||
}
|
||||
|
||||
export type WorkspaceAuxiliaryPaneRole = "supplementary" | "inspector";
|
||||
|
||||
export function deriveLayout(input: { readonly width: number; readonly height: number }): Layout {
|
||||
|
||||
Reference in new issue
Block a user