Skip to content

Commit 152577a

Browse files
committed
fix(mobile): Home opens below the header
Home restored its saved scroll offset on mount as well as when search closed. React Native's iOS scrollTo clamps against the raw contentInset, which excludes the header inset UIKit adds, so that scroll could leave the first rows under the header. Restore only when search returns to resting, and let programmatic scrolls reach the automatic header inset, as the thread feed already does.
1 parent dd14848 commit 152577a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,9 +316,14 @@ export function HomeScreen(props: HomeScreenProps) {
316316
const listRef = useRef<LegendListRef>(null);
317317
const searchMode = workspace?.state.tabs.threads.searchMode;
318318
const restoredOffset = workspace?.state.tabs.threads.scrollOffset;
319+
// Only a return from search restores. On mount, UIKit already rests the list
320+
// below the header, and a scroll here would use an unmeasured header inset.
321+
const previousSearchMode = useRef(searchMode);
319322
// oxlint-disable-next-line t3code/no-unreasoned-state-sync -- restores the thread list's saved scroll offset through the list ref when search goes back to resting
320323
useEffect(() => {
321-
if (searchMode !== "resting" || restoredOffset === undefined) return;
324+
const restoringSearch = previousSearchMode.current !== "resting" && searchMode === "resting";
325+
previousSearchMode.current = searchMode;
326+
if (!restoringSearch || restoredOffset === undefined) return;
322327
listRef.current?.scrollToOffset({
323328
offset: restoredOffset - (Platform.OS === "ios" ? insets.top : 0),
324329
animated: false,
@@ -813,6 +818,8 @@ export function HomeScreen(props: HomeScreenProps) {
813818
// the list in the same frame as the bar.
814819
contentInsetAdjustmentBehavior="automatic"
815820
contentInsetStartAdjustment={Platform.OS === "ios" ? insets.top : 0}
821+
// RN scrollTo clamps against raw insets and ignores the automatic bar inset.
822+
scrollToOverflowEnabled
816823
initialScrollOffset={
817824
initialScrollOffset > 0
818825
? initialScrollOffset - (Platform.OS === "ios" ? insets.top : 0)

0 commit comments

Comments
 (0)