Skip to content

Commit a0f15a0

Browse files
fix(mobile): size unmeasured drag rows with each list's own estimate
The drag surface now takes the list's estimatedItemSize instead of a fixed 72 pt, so the sidebar's 64 pt rows hit-test at the right midpoint before they are measured. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
1 parent 63d413a commit a0f15a0

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

‎apps/mobile/src/features/home/HomeScreen.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,7 @@ export function HomeScreen(props: HomeScreenProps) {
981981
<SwipeableScrollGateProvider enabled={swipeEnabled} activation={swipeRowActivation}>
982982
<ThreadListDragSurface
983983
listRef={listRef}
984+
estimatedRowHeight={ESTIMATED_THREAD_LIST_V2_ROW_HEIGHT}
984985
items={threadListV2Items}
985986
workingShelfEnabled={workingShelfEnabled}
986987
edgeInsets={dragEdgeInsets}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ type SidebarListItem =
8686
| { readonly type: "v2-show-more"; readonly key: string; readonly hiddenCount: number };
8787

8888
const SIDEBAR_STICKY_HEADER_HEIGHT = 106;
89+
const SIDEBAR_ESTIMATED_ROW_HEIGHT = 64;
8990

9091
interface ThreadNavigationSidebarProps {
9192
readonly width: number;
@@ -937,6 +938,7 @@ function ThreadNavigationSidebarPane(
937938
<SwipeableScrollGateProvider enabled={swipeEnabled}>
938939
<ThreadListDragSurface
939940
listRef={listRef}
941+
estimatedRowHeight={SIDEBAR_ESTIMATED_ROW_HEIGHT}
940942
items={listItems}
941943
workingShelfEnabled={workingShelfEnabled}
942944
edgeInsets={nativeDragEdgeInsets}
@@ -949,7 +951,7 @@ function ThreadNavigationSidebarPane(
949951
{...dragListProps}
950952
data={listItems}
951953
drawDistance={500}
952-
estimatedItemSize={64}
954+
estimatedItemSize={SIDEBAR_ESTIMATED_ROW_HEIGHT}
953955
extraData={listExtraData}
954956
getItemType={(item) => item.type}
955957
itemsAreEqual={sidebarItemsAreEqual}
@@ -1015,6 +1017,7 @@ function ThreadNavigationSidebarPane(
10151017
<SwipeableScrollGateProvider enabled={swipeEnabled}>
10161018
<ThreadListDragSurface
10171019
listRef={listRef}
1020+
estimatedRowHeight={SIDEBAR_ESTIMATED_ROW_HEIGHT}
10181021
items={listItems}
10191022
workingShelfEnabled={workingShelfEnabled}
10201023
// The iOS sticky header overlays the padded list.
@@ -1032,7 +1035,7 @@ function ThreadNavigationSidebarPane(
10321035
{...dragListProps}
10331036
data={listItems}
10341037
drawDistance={500}
1035-
estimatedItemSize={64}
1038+
estimatedItemSize={SIDEBAR_ESTIMATED_ROW_HEIGHT}
10361039
extraData={listExtraData}
10371040
getItemType={(item) => item.type}
10381041
itemsAreEqual={sidebarItemsAreEqual}

‎apps/mobile/src/features/threads/thread-list-drag.tsx‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const PRESS_SLOP = 10;
5252
const LIFT_SLOP = 6;
5353
const AUTO_SCROLL_EDGE = 56;
5454
// Matches the lists' estimatedItemSize for rows LegendList has not measured.
55-
const ESTIMATED_ROW_HEIGHT = 72;
5655

5756
interface DragLayout {
5857
readonly sourceKey: string;
@@ -166,11 +165,12 @@ function createDropPolicy(
166165
function snapshotRows(
167166
state: LegendListState,
168167
items: readonly { readonly type: string; readonly key: string }[],
168+
estimatedRowHeight: number,
169169
) {
170170
const geometry = completeThreadDragGeometry(
171171
items.map((item, index) => state.positionByKey(item.key) ?? state.positionAtIndex(index)),
172172
items.map((item) => state.sizes.get(item.key)),
173-
ESTIMATED_ROW_HEIGHT,
173+
estimatedRowHeight,
174174
);
175175
const rows: ThreadDragRow[] = [];
176176
const offsets: Record<string, number> = {};
@@ -203,6 +203,8 @@ export function ThreadListDragSurface(props: {
203203
readonly listRef: RefObject<LegendListRef | null>;
204204
readonly items: readonly { readonly type: string; readonly key: string }[];
205205
readonly workingShelfEnabled: boolean;
206+
/** The list's `estimatedItemSize`, used for rows it has not measured yet. */
207+
readonly estimatedRowHeight: number;
206208
/** Content hidden under translucent chrome, kept out of the auto-scroll edges.
207209
* `scrollInsetTop` is how far above zero the list may scroll; it defaults to
208210
* `top` for native automatic insets and is 0 when the list pads its content. */
@@ -244,7 +246,7 @@ export function ThreadListDragSurface(props: {
244246
// LegendList's current layout and the scroll offset it actually applied.
245247
const measure = (current: Drag, state: LegendListState) => {
246248
current.scroll = state.scroll;
247-
const snapshot = snapshotRows(state, latest.current.items);
249+
const snapshot = snapshotRows(state, latest.current.items, latest.current.estimatedRowHeight);
248250
if (snapshot.version === current.geometryVersion) return false;
249251
const source = snapshot.rows.find((row) => row.key === current.itemKey);
250252
current.rows = snapshot.rows;
@@ -345,7 +347,11 @@ export function ThreadListDragSurface(props: {
345347
const list = latest.current.listRef.current;
346348
if (list === null || drag.current !== null) return;
347349
const state = list.getState();
348-
const snapshot = snapshotRows(state, latest.current.items);
350+
const snapshot = snapshotRows(
351+
state,
352+
latest.current.items,
353+
latest.current.estimatedRowHeight,
354+
);
349355
const source = snapshot.rows.find((row) => row.key === itemKey);
350356
if (source === undefined || (source.section !== "pinned" && source.section !== "active"))
351357
return;

0 commit comments

Comments
 (0)