GeezerVison is showing github.com — fix(mobile): sidebar toggle works on iPad and iPhone Duo by mweinbach · Pull Request #20406 · pingdotgg/t3code
fix(mobile): sidebar toggle works on iPad and iPhone Duo
#20406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.ts
(2)
.tsx
(3)
All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -38,6 +38,7 @@ import {
deriveLayout,
type VerticalHinge,
deriveWorkspacePaneLayout,
isPrimarySidebarPinned,
type FileInspectorPaneLayout,
type Layout,
type WorkspaceAuxiliaryPaneRole,
Expand Down
Expand Up
@@ -245,7 +246,6 @@ function AdaptiveWorkspaceLayoutContent(
const navigation = useNavigation();
const activeRoleOwner = useRef<symbol | null>(null);
const [primarySidebarPreferredVisible, setPrimarySidebarPreferredVisible] = useState(true);
const showPrimarySidebar = pathname === "/" || primarySidebarPreferredVisible;
const [supplementaryPanePreferredVisible, setSupplementaryPanePreferredVisible] = useState(true);
const [supplementaryPanePreferredWidth, setSupplementaryPanePreferredWidth] = useState<
number | null
Expand All
@@ -261,6 +261,12 @@ function AdaptiveWorkspaceLayoutContent(
() => deriveLayout({ width: viewportWidth, height, nativeMetrics }),
[height, viewportWidth, nativeMetrics],
);
const primarySidebarPinned = isPrimarySidebarPinned({
pathname,
nativeWorkspace,
usesSplitView: baseLayout.usesSplitView,
});
const showPrimarySidebar = primarySidebarPinned || primarySidebarPreferredVisible;
const shouldRenderNavigationRail = Platform.OS === "android" && baseLayout.usesSplitView;
const navigationRailWidth =
shouldRenderNavigationRail && showPrimarySidebar
Expand Down
Expand Up
@@ -378,7 +384,7 @@ function AdaptiveWorkspaceLayoutContent(
};
}, []);
const togglePrimarySidebar = useCallback(() => {
if (pathname === "/" ) {
if (primarySidebarPinned ) {
return;
}
if (!panes.primarySidebarVisible && panes.primarySidebarSuppressedByAuxiliary) {
Expand All
@@ -387,7 +393,11 @@ function AdaptiveWorkspaceLayoutContent(
return;
}
setPrimarySidebarPreferredVisible((current) => !current);
}, [panes.primarySidebarSuppressedByAuxiliary, panes.primarySidebarVisible, pathname]);
}, [
panes.primarySidebarSuppressedByAuxiliary,
panes.primarySidebarVisible,
primarySidebarPinned,
]);
const revealPrimarySidebar = useCallback(() => {
if (panes.primarySidebarSuppressedByAuxiliary) {
setFileInspectorPreferredVisible(false);
Expand All
@@ -399,8 +409,8 @@ function AdaptiveWorkspaceLayoutContent(
return true;
}, [togglePrimarySidebar]);
const sidebarCommands = useMemo(
() => (pathname === "/" ? [] : (["toggleSidebar"] as const)),
[pathname ],
() => (primarySidebarPinned ? [] : (["toggleSidebar"] as const)),
[primarySidebarPinned ],
);
useHardwareKeyboardCommand(sidebarCommands, handleToggleSidebarCommand);
const showAuxiliaryPane = useCallback((role: WorkspaceAuxiliaryPaneRole) => {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -23,11 +23,10 @@ import { use, useCallback, useEffect, useMemo, useRef, useState, type ComponentP
import { View } from "react-native";
import { Split, type SplitHostCommands } from "react-native-screens";
import { EnvironmentId, ThreadId } from "@t3tools/contracts";
import { isDuoDevice } from "../../lib/device-type";
import { scopedThreadKey } from "../../lib/scopedEntities";
import { WorkspaceTabsProvider } from "../workspace/WorkspaceTabsContext";
import { WorkspaceNativeTabs } from "../workspace/WorkspaceNativeTabs.ios";
import { useDeviceType, useNativeLayoutMetrics } from "../../native/native-layout-metrics";
import { useNativeLayoutMetrics } from "../../native/native-layout-metrics";
import { useAdaptiveWorkspaceLayout } from "./AdaptiveWorkspaceLayout";
import { WorkspaceEmptyDetail } from "./WorkspaceEmptyDetail";
Expand All
@@ -43,7 +42,6 @@ import {
} from "../../native/NativeWorkspaceColumns";
import { V5StackHeader } from "../../native/V5StackHeader.ios";
import type { AppNativeStackNavigationOptions } from "../../native/StackHeader";
import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import {
nativeWorkspacePopAction,
projectWorkspaceStack,
Expand Down
Expand Up
@@ -125,7 +123,6 @@ function WorkspaceColumns(
props: ViewProps & { readonly primary: Route; readonly detail: Route[] },
) {
const { layout, panes, togglePrimarySidebar, toggleAuxiliaryPane } = useAdaptiveWorkspaceLayout();
const deviceType = useDeviceType();
const inspector = use(NativeWorkspaceInspectorContext);
const hostRef = useRef<SplitHostCommands>(null);
const activeDetailKey = props.detail.at(-1)?.key;
Expand Down
Expand Up
@@ -185,7 +182,9 @@ function WorkspaceColumns(
preferredSplitBehavior="tile"
topColumnForCollapsing={compactColumn}
preferredDisplayMode={
panes.primarySidebarVisible || !activeDetailKey ? "oneBesideSecondary" : "secondaryOnly"
panes.primarySidebarVisible || (!layout.usesSplitView && !activeDetailKey)
? "oneBesideSecondary"
: "secondaryOnly"
}
displayModeButtonVisibility="never"
presentsWithGesture
Expand Down
Expand Up
@@ -222,21 +221,6 @@ function WorkspaceColumns(
options={{
headerShown: true,
title: "",
unstable_headerRightItems: () =>
isDuoDevice(deviceType) && layout.usesSplitView && !panes.primarySidebarVisible
? [
{
type: "button",
axisBehavior: "verticalPreferred",
accessibilityLabel: "Search threads",
label: "Search threads",
icon: { type: "sfSymbol", name: "magnifyingglass" },
onPress: () => {
dispatchHardwareKeyboardCommand("focusSearch");
},
},
]
: [],
unstable_headerLeftItems: () => [
{
type: "button",
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -6,7 +6,6 @@ import { useDeviceType } from "../../native/native-layout-metrics";
import { useNativeWorkspaceColumnsSupported } from "../../native/NativeWorkspaceColumns";
import { useAdaptiveWorkspaceLayout } from "../layout/AdaptiveWorkspaceLayout";
import { withNativeGlassHeaderItem } from "../layout/native-glass-header-items";
import { dispatchHardwareKeyboardCommand } from "../keyboard/hardwareKeyboardCommands";
import {
ThreadGitControls,
useThreadGitCenterHeaderItems,
Expand Down
Expand Up
@@ -105,21 +104,6 @@ export function useThreadHeaderOptions(props: {
() => [
...threadCenterHeaderItems,
{ type: "spacing", spacing: 8 },
...(layout.usesSplitView && !panes.primarySidebarVisible
? [
withNativeGlassHeaderItem({
type: "button" as const,
axisBehavior: "verticalPreferred",
identifier: "thread-right-search",
label: "Search threads",
accessibilityLabel: "Search threads",
icon: { name: "magnifyingglass", type: "sfSymbol" as const },
onPress: () => {
dispatchHardwareKeyboardCommand("focusSearch");
},
}),
]
: []),
withNativeGlassHeaderItem({
type: "button" as const,
axisBehavior: "verticalPreferred",
Expand All
@@ -130,7 +114,7 @@ export function useThreadHeaderOptions(props: {
onPress: () => navigation.navigate("NewTaskSheet", { screen: "NewTask" }),
}),
],
[navigation, threadCenterHeaderItems, layout.usesSplitView, panes.primarySidebarVisible ],
[navigation, threadCenterHeaderItems],
);
const options: AppNativeStackNavigationOptions = {
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -9,6 +9,7 @@ import {
deriveThreadFeedInitialContentInset,
deriveThreadWorkLogSizing,
deriveWorkspacePaneLayout,
isPrimarySidebarPinned,
SPLIT_LAYOUT_MIN_HEIGHT,
SPLIT_LAYOUT_MIN_WIDTH,
} from "./layout";
Expand Down
Expand Up
@@ -161,6 +162,36 @@ describe("deriveLayout", () => {
});
});
describe("isPrimarySidebarPinned", () => {
it("lets native split columns collapse the sidebar on the workspace root", () => {
expect(
isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: true, usesSplitView: true }),
).toBe(false);
});
it("keeps compact native roots pinned so search cannot hide the sidebar for a later split", () => {
expect(
isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: true, usesSplitView: false }),
).toBe(true);
});
it("keeps the JS split layout pinned on the workspace root", () => {
expect(
isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: false, usesSplitView: true }),
).toBe(true);
});
it("never pins outside the workspace root", () => {
expect(
isPrimarySidebarPinned({
pathname: "/threads/a/b",
nativeWorkspace: false,
usesSplitView: true,
}),
).toBe(false);
});
});
describe("deriveWorkspacePaneLayout", () => {
it("keeps the auxiliary pane out of a standard iPad detail column", () => {
const layout = deriveLayout({ width: 1_194, height: 834 });
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -158,6 +158,20 @@ export function alignListPaneToHinge(input: {
return { ...layout, listPaneWidth, listPaneGap: hinge.width };
}
/**
* Whether the workspace root must keep the primary sidebar open. Native split
* columns keep a sidebar toggle in the empty detail header, so only they may
* collapse it there. Compact layouts stay pinned so a reveal request (such as
* focusing search) cannot flip the saved preference for a later split view.
*/
export function isPrimarySidebarPinned(input: {
readonly pathname: string;
readonly nativeWorkspace: boolean;
readonly usesSplitView: boolean;
}): boolean {
return input.pathname === "/" && !(input.nativeWorkspace && input.usesSplitView);
}
export function deriveWorkspacePaneLayout(input: {
readonly layout: Layout;
readonly viewportWidth: number;
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.