Skip to content

Commit 10e617c

Browse files
fix(mobile): iPhone Settings search keeps its query after switching tabs
On iPhone, Home draws the Settings list under the pushed Settings route, so the toolbar was neither focused nor in a presented column and never put the saved query back into the native search bar. Treat the Settings route on top of the workspace stack as the search host being visible. Fixes #28247 AI-assisted; verified with the tests and tools listed above.
1 parent dbfbe39 commit 10e617c

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎apps/mobile/src/features/layout/workspace/WorkspaceToolbar.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useActiveNewTask } from "../../../state/active-new-task";
22
import { Toolbar } from "../../../components/ui/Toolbar";
3-
import { useFocusEffect, useIsFocused } from "@react-navigation/native";
3+
import { useFocusEffect, useIsFocused, useNavigationState } from "@react-navigation/native";
44
import { use, useCallback, useEffect, useRef } from "react";
55
import { isDuoDevice } from "../../../lib/device-type";
66
import { useDeviceType } from "../../../native/native-layout-metrics";
@@ -89,8 +89,12 @@ export function WorkspaceToolbar(props: {
8989
? enterSearch()
9090
: workspace.dispatch({ type: "search", tab: selectedTab });
9191
useHardwareKeyboardCommand("focusSearch", focusSearch);
92+
// Home draws the Settings list under the `Settings` route, which holds navigation focus.
93+
const settingsListOnTop = useNavigationState(
94+
(state) => state.routes[state.index]?.name === "Settings",
95+
);
9296
// The sidebar remains visible while its detail owns navigation focus.
93-
const searchHostVisible = focused || primaryColumn?.presented === true;
97+
const searchHostVisible = focused || settingsListOnTop || primaryColumn?.presented === true;
9498
const restoreSearch = () => {
9599
if (
96100
searchHostVisible &&

0 commit comments

Comments
 (0)