Skip to content

Commit bca63a5

Browse files
committed
fix(mobile): open a detail for wide Android Settings actions
1 parent c37cb68 commit bca63a5

3 files changed

Lines changed: 48 additions & 3 deletions

File tree

‎apps/mobile/src/features/layout/AdaptiveWorkspaceLayout.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,10 @@ import {
9595
currentWorkspaceSelections,
9696
workspaceSelectionCheck,
9797
} from "../workspace/workspace-selection-store";
98-
import { workspaceTabNavigationState } from "../workspace/workspace-tab-navigation";
98+
import {
99+
workspaceTabColumns,
100+
workspaceTabNavigationState,
101+
} from "../workspace/workspace-tab-navigation";
99102
import type { WorkspaceTab } from "../workspace/workspace-tabs-state";
100103
import { workspaceRoutesOf } from "./workspace-overlay-routes";
101104
import { SettingsWorkspaceLayout } from "../settings/SettingsWorkspaceLayout";
@@ -479,7 +482,7 @@ function AdaptiveWorkspaceLayoutContent(
479482
tab,
480483
currentWorkspaceSelections(),
481484
{
482-
columns: Platform.OS === "ios" && (options?.columns ?? layout.usesSplitView),
485+
columns: workspaceTabColumns(Platform.OS, tab, options?.columns ?? layout.usesSplitView),
483486
check: workspaceSelectionCheck,
484487
overlays,
485488
},

‎apps/mobile/src/features/workspace/workspace-tab-navigation.test.ts‎

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
import { describe, expect, it } from "vite-plus/test";
22

33
import { restoreSettingsLinkState } from "../settings/settings-navigation";
4-
import { workspaceSelectionsIn, workspaceTabNavigationState } from "./workspace-tab-navigation";
4+
import {
5+
workspaceSelectionsIn,
6+
workspaceTabColumns,
7+
workspaceTabNavigationState,
8+
} from "./workspace-tab-navigation";
59

610
const home = { key: "home", name: "Home" };
711
const thread = {
@@ -47,6 +51,36 @@ describe("workspace tab selections", () => {
4751
describe("opening a workspace tab", () => {
4852
const columns = { columns: true, check: available };
4953

54+
it("opens Android Settings beside its default page only in a wide window", () => {
55+
const open = (wide: boolean) =>
56+
workspaceTabNavigationState(
57+
{ routes: [home, thread] },
58+
"settings",
59+
{},
60+
{
61+
columns: workspaceTabColumns("android", "settings", wide),
62+
check: available,
63+
},
64+
);
65+
expect(names(open(false))).toEqual(["Home", "Settings"]);
66+
expect(names(open(true))).toEqual(["Home", "Settings", "SettingsEnvironments"]);
67+
});
68+
69+
it("keeps Android list tabs and iOS remembered-detail navigation unchanged", () => {
70+
const open = (platform: string) =>
71+
workspaceTabNavigationState(
72+
{ routes: [home, thread] },
73+
"threads",
74+
{ threads: thread.params },
75+
{
76+
columns: workspaceTabColumns(platform, "threads", true),
77+
check: available,
78+
},
79+
);
80+
expect(names(open("android"))).toEqual(["Home"]);
81+
expect(names(open("ios"))).toEqual(["Home", "Thread"]);
82+
});
83+
5084
it("opens the remembered page beside the list with columns, and the list without", () => {
5185
const state = { routes: [home, thread] };
5286
const selections = { threads: thread.params, pullRequests: pullRequest.params };

‎apps/mobile/src/features/workspace/workspace-tab-navigation.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ type PullRequestSelection = NonNullable<WorkspaceSelections["pullRequests"]>;
1717
/** Opened when Settings has columns and none of its pages has been opened yet. */
1818
export const DEFAULT_SETTINGS_PAGE = "SettingsEnvironments" satisfies SettingsPageTarget;
1919

20+
export function workspaceTabColumns(
21+
platform: string,
22+
tab: WorkspaceTab | "settings",
23+
columns: boolean,
24+
) {
25+
return columns && (platform === "ios" || (platform === "android" && tab === "settings"));
26+
}
27+
2028
// Pages a Settings row opens, minus Project overview: it shows the project chosen in the
2129
// Settings scope, which resets whenever Settings closes.
2230
const REMEMBERED_SETTINGS_PAGES: ReadonlySet<string> = new Set(

0 commit comments

Comments
 (0)