Skip to content

Commit b901e09

Browse files
committed
fix(mobile): New thread's project picker can be cancelled from an empty split view
In split view the picker opened with no thread selected is the detail column's first page, so it had no back button and swipe-back did nothing. It now shows a Cancel button there, which returns to the empty pane. Over an open page it keeps the native back button.
1 parent 7b63780 commit b901e09

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import {
77
StackActions,
88
useIsFocused,
99
useNavigation,
10+
useNavigationState,
11+
useRoute,
1012
type StaticScreenProps,
1113
} from "@react-navigation/native";
1214
import { SymbolView } from "../../components/ui/AppSymbol";
@@ -122,6 +124,13 @@ function NewTaskHeader(props: {
122124
readonly onSearchTextChange: (text: string) => void;
123125
}) {
124126
const navigation = useNavigation();
127+
const routeKey = useRoute().key;
128+
// Split view's detail column leaves out Home and Settings, so a picker opened over either is the
129+
// column's first page, with no native back button.
130+
const firstDetailPage = useNavigationState((state) => {
131+
const below = state.routes[state.routes.findIndex((route) => route.key === routeKey) - 1];
132+
return below === undefined || below.name === "Home" || below.name === "Settings";
133+
});
125134
const goBack = () => {
126135
if (navigation.canGoBack()) navigation.goBack();
127136
else navigation.getParent()?.goBack();
@@ -135,6 +144,9 @@ function NewTaskHeader(props: {
135144
options={{ headerBackVisible: true }}
136145
hideBottomBorder
137146
onBack={goBack}
147+
backInSplitView={
148+
firstDetailPage ? { accessibilityLabel: "Cancel", icon: "xmark" } : undefined
149+
}
138150
actions={
139151
props.canAddProject
140152
? [

0 commit comments

Comments
 (0)