Skip to content

Commit 3a382a1

Browse files
fix(web): titlebar controls hide while the mobile sidebar is open
On narrow viewports the sidebar opens as a sheet at z-46, but the right-hand workspace titlebar controls sit at z-50, so they drew over the open sheet and still took taps. Hide them while the mobile sheet is mounted, the way the left sidebar toggle already does, through one null-safe useMobileSidebarSheetMounted hook shared by all four controls. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 32ecd71 commit 3a382a1

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() {
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);
@@ -376,7 +378,7 @@ function SidebarControl() {
376378
ref={appShellCommandsRef}
377379
className={cn(
378380
"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",
379-
isMobile && mobileSheetMounted && "hidden",
381+
mobileSidebarSheetMounted && "hidden",
380382
)}
381383
data-sidebar-control=""
382384
>

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

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

88
import type { ThreadPanelPresentation } from "../../rightPanelLayout";
99
import { PopoverCreateHandle, PopoverTrigger } from "../ui/popover";
10+
import { useMobileSidebarSheetMounted } from "../ui/sidebar";
1011
import { Toggle } from "../ui/toggle";
1112
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
1213

@@ -163,9 +164,13 @@ export const RightPanelMaximizeControl = memo(function RightPanelMaximizeControl
163164

164165
/** The thread panel toggle on a header whose right side the inline right panel covers. */
165166
export function ThreadPanelHeaderControl(props: PanelLayoutControlsProps) {
167+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
166168
return (
167169
<div
168-
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]"
170+
className={cn(
171+
"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]",
172+
mobileSidebarSheetMounted && "hidden",
173+
)}
169174
data-workspace-titlebar-controls
170175
>
171176
<PanelLayoutControls {...props} showTerminalControl={false} showRightPanelControl={false} />
@@ -182,9 +187,13 @@ export function WorkspaceTitlebarControls(props: {
182187
readonly onToggleMaximized: () => void;
183188
readonly children: ReactNode;
184189
}) {
190+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
185191
return (
186192
<div
187-
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]"
193+
className={cn(
194+
"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]",
195+
mobileSidebarSheetMounted && "hidden",
196+
)}
188197
data-workspace-titlebar-controls
189198
>
190199
{props.showMaximizeControl ? (

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import { registerCommands } from "~/shortcuts/dispatcher";
8282
import { isTerminalFocused } from "~/lib/terminalFocus";
8383
import { PanelLayoutControls, RightPanelMaximizeControl } from "../chat/PanelLayoutControls";
8484
import { Button } from "../ui/button";
85-
import { SidebarInset } from "../ui/sidebar";
85+
import { SidebarInset, useMobileSidebarSheetMounted } from "../ui/sidebar";
8686
import { useLiveRefresh } from "~/hooks/useLiveRefresh";
8787
import { useStableCallback } from "~/hooks/useStableCallback";
8888
import { useOpenPanelPullRequestUrl } from "~/hooks/useOpenPanelPullRequestUrl";
@@ -1011,6 +1011,7 @@ export function PullRequestsPage() {
10111011
},
10121012
);
10131013
const rightPanelAvailable = selectedPullRequestSurface !== null;
1014+
const mobileSidebarSheetMounted = useMobileSidebarSheetMounted();
10141015
const [maximized, setMaximized] = useState(false);
10151016
const rightPanelMaximized = rightPanelState.isOpen && maximized;
10161017
if (!rightPanelState.isOpen && maximized) setMaximized(false);
@@ -1120,7 +1121,10 @@ export function PullRequestsPage() {
11201121
);
11211122
const openPanelControls = (
11221123
<div
1123-
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]"
1124+
className={cn(
1125+
"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]",
1126+
mobileSidebarSheetMounted && "hidden",
1127+
)}
11241128
data-workspace-titlebar-controls
11251129
>
11261130
{rightPanelState.isOpen ? (

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

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

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

@@ -859,6 +865,7 @@ export {
859865
SidebarProvider,
860866
SidebarRail,
861867
SidebarTrigger,
868+
useMobileSidebarSheetMounted,
862869
useSidebar,
863870
useSidebarVisibility,
864871
};

0 commit comments

Comments
 (0)