Skip to content

Commit 0629735

Browse files
fix(web): thread controls hide while the mobile sidebar is open (pingdotgg#27490)
Co-authored-by: Claude Opus 5.5 <[email protected]>
1 parent 5534467 commit 0629735

4 files changed

Lines changed: 28 additions & 6 deletions

File tree

‎apps/web/src/components/AppSidebarLayout.tsx‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
SidebarProvider,
5858
SidebarRail,
5959
SidebarTrigger,
60+
useMobileSidebarSheetMounted,
6061
useSidebar,
6162
useSidebarVisibility,
6263
} from "./ui/sidebar";
@@ -316,7 +317,8 @@ function SidebarControl({ showSidebar }: { readonly showSidebar: boolean }) {
316317
const router = useRouter();
317318
const usagePageOpen = useLocation({ select: (location) => location.pathname === "/usage" });
318319
const keybindings = useAtomValue(primaryServerKeybindingsAtom);
319-
const { toggleSidebar, isMobile, mobileSheetMounted } = useSidebar();
320+
const { toggleSidebar } = useSidebar();
321+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
320322
const isSidebarVisible = useSidebarVisibility();
321323
const environmentIdentificationMode = useEnvironmentIdentificationMode();
322324
const stageBackdropVariant = useSidebarStageBackdropVariant(environmentIdentificationMode);
@@ -378,7 +380,7 @@ function SidebarControl({ showSidebar }: { readonly showSidebar: boolean }) {
378380
ref={appShellCommandsRef}
379381
className={cn(
380382
"pointer-events-none fixed left-[var(--workspace-controls-left)] top-[var(--workspace-controls-top)] z-50 ml-px flex h-[var(--workspace-topbar-height)] items-center",
381-
isMobile && mobileSheetMounted && "hidden",
383+
mobileSidebarSheetMounted && "hidden",
382384
)}
383385
data-sidebar-control=""
384386
>

‎apps/web/src/components/chat/PanelLayoutControls.tsx‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { cn } from "~/lib/utils";
1111

1212
import type { ThreadPanelPresentation } from "../../rightPanelLayout";
1313
import { PopoverCreateHandle, PopoverTrigger } from "../ui/popover";
14+
import { useMobileSidebarSheetMounted } from "../ui/sidebar";
1415
import { Toggle } from "../ui/toggle";
1516
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
1617

@@ -171,9 +172,13 @@ export const RightPanelMaximizeControl = memo(function RightPanelMaximizeControl
171172

172173
/** The thread panel toggle on a header whose right side the inline right panel covers. */
173174
export function ThreadPanelHeaderControl(props: PanelLayoutControlsProps) {
175+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
174176
return (
175177
<div
176-
className="absolute top-[var(--workspace-controls-top)] right-[calc(env(safe-area-inset-right)+0.75rem)] z-50 flex h-[var(--workspace-topbar-height)] items-center [-webkit-app-region:no-drag]"
178+
className={cn(
179+
"absolute top-[var(--workspace-controls-top)] right-[calc(env(safe-area-inset-right)+0.75rem)] z-50 flex h-[var(--workspace-topbar-height)] items-center [-webkit-app-region:no-drag]",
180+
mobileSidebarSheetMounted && "hidden",
181+
)}
177182
data-workspace-titlebar-controls
178183
>
179184
<PanelLayoutControls {...props} showTerminalControl={false} showRightPanelControl={false} />
@@ -190,9 +195,13 @@ export function WorkspaceTitlebarControls(props: {
190195
readonly onToggleMaximized: () => void;
191196
readonly children: ReactNode;
192197
}) {
198+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
193199
return (
194200
<div
195-
className="pointer-events-none fixed top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]"
201+
className={cn(
202+
"pointer-events-none fixed top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
203+
mobileSidebarSheetMounted && "hidden",
204+
)}
196205
data-workspace-titlebar-controls
197206
>
198207
{props.showMaximizeControl ? (

‎apps/web/src/components/pullRequest/PullRequestsPage.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ import { registerCommands } from "~/shortcuts/dispatcher";
8686
import { isTerminalFocused } from "~/lib/terminalFocus";
8787
import { PanelLayoutControls, RightPanelMaximizeControl } from "../chat/PanelLayoutControls";
8888
import { Button } from "../ui/button";
89-
import { SidebarInset } from "../ui/sidebar";
89+
import { SidebarInset, useMobileSidebarSheetMounted } from "../ui/sidebar";
9090
import { useLiveRefresh } from "~/hooks/useLiveRefresh";
9191
import { useStableCallback } from "~/hooks/useStableCallback";
9292
import { useOpenPanelPullRequestUrl } from "~/hooks/useOpenPanelPullRequestUrl";
@@ -1045,6 +1045,7 @@ export function PullRequestsPage() {
10451045
},
10461046
);
10471047
const rightPanelAvailable = selectedPullRequestSurface !== null;
1048+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
10481049
const [maximized, setMaximized] = useState(false);
10491050
const rightPanelMaximized = rightPanelState.isOpen && maximized;
10501051
if (!rightPanelState.isOpen && maximized) setMaximized(false);
@@ -1160,7 +1161,10 @@ export function PullRequestsPage() {
11601161
);
11611162
const openPanelControls = (
11621163
<div
1163-
className="absolute top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]"
1164+
className={cn(
1165+
"absolute top-[var(--workspace-controls-top)] right-[var(--workspace-controls-right)] z-50 mr-px flex h-[var(--workspace-topbar-height)] items-center gap-1 [-webkit-app-region:no-drag]",
1166+
mobileSidebarSheetMounted && "hidden",
1167+
)}
11641168
data-workspace-titlebar-controls
11651169
>
11661170
{rightPanelState.isOpen ? (

‎apps/web/src/components/ui/sidebar.tsx‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ function useSidebarVisibility() {
9898
return isMobile ? openMobile : open;
9999
}
100100

101+
/** Whether the mobile sidebar sheet covers the page; false outside a SidebarProvider. */
102+
function useMobileSidebarSheetMounted() {
103+
const context = React.use(SidebarContext);
104+
return context !== null && context.isMobile && context.mobileSheetMounted;
105+
}
106+
101107
// The `max-md` breakpoint, also read when a shortcut fires.
102108
const SIDEBAR_MOBILE_QUERY = "(max-width: 767px)";
103109

@@ -869,6 +875,7 @@ export {
869875
SidebarProvider,
870876
SidebarRail,
871877
SidebarTrigger,
878+
useMobileSidebarSheetMounted,
872879
useSidebar,
873880
useSidebarVisibility,
874881
};

0 commit comments

Comments
 (0)