Skip to content

Commit 115739c

Browse files
authored
fix(web): keep the project filter menu aligned with its trigger
1 parent e53672d commit 115739c

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,7 +1032,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
10321032
const projectScopeFilter = useComboboxFilter();
10331033
const allProjectSnapshotsReady = useAllEnvironmentProjectSnapshotsReady();
10341034
const allProjectConfigsReady = useAtomValue(environmentProjects.projectConfigsReadyAtom);
1035-
const headerSearchRef = useRef<HTMLDivElement | null>(null);
10361035
// Safari may click after Ctrl+click opens settings; suppress that selection until the picker reopens.
10371036
const suppressNextScopeChangeRef = useRef(false);
10381037
const highlightedProjectScopeKeyRef = useRef<string | null>(null);
@@ -2990,7 +2989,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
29902989
fixedHeader={
29912990
<SidebarGroup className="z-[1]">
29922991
<SidebarThreadHeader
2993-
searchFieldRef={headerSearchRef}
29942992
hasProjects={projectGroups.length > 0}
29952993
projectScope={
29962994
<Combobox
@@ -3061,8 +3059,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
30613059
{/* Refocusing the trigger after a pointer close shows its focus ring and opens its tooltip. */}
30623060
<ComboboxPopup
30633061
align="start"
3064-
anchor={headerSearchRef}
3065-
className="max-w-[min(18rem,var(--available-width))] overflow-hidden"
3062+
collisionAvoidance={{ side: "flip", align: "shift" }}
3063+
className="w-[min(18rem,var(--available-width))] overflow-hidden"
30663064
finalFocus={(closeType) => closeType === "keyboard"}
30673065
>
30683066
<ComboboxSearchInput

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { SidebarInput, SidebarMenuButton } from "../ui/sidebar";
1313
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
1414

1515
export interface SidebarThreadHeaderProps {
16-
searchFieldRef?: RefObject<HTMLDivElement | null>;
1716
hasProjects: boolean;
1817
projectScope: ReactNode;
1918
onNewProject: () => void;
@@ -33,7 +32,6 @@ export interface SidebarThreadHeaderProps {
3332
}
3433

3534
export function SidebarThreadHeader({
36-
searchFieldRef,
3735
hasProjects,
3836
projectScope,
3937
onNewProject,
@@ -60,10 +58,7 @@ export function SidebarThreadHeader({
6058

6159
return (
6260
<div className="flex items-center gap-1">
63-
<div
64-
ref={searchFieldRef}
65-
className="flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-within:bg-sidebar-row-hover focus-within:text-sidebar-foreground focus-within:ring-1 focus-within:ring-inset focus-within:ring-ring/70"
66-
>
61+
<div className="flex h-8 min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-sm font-medium text-sidebar-muted-foreground hover:bg-sidebar-row-hover hover:text-sidebar-foreground focus-within:bg-sidebar-row-hover focus-within:text-sidebar-foreground focus-within:ring-1 focus-within:ring-inset focus-within:ring-ring/70">
6762
<SearchIcon className="size-4 shrink-0 text-(--sidebar-icon-color)" />
6863
<SidebarInput
6964
ref={searchInputRef}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ function ComboboxPopup({
139139
sideOffset = 4,
140140
alignOffset,
141141
align = "start",
142+
collisionAvoidance,
142143
anchor: anchorProp,
143144
...props
144145
}: ComboboxPrimitive.Popup.Props & {
@@ -147,6 +148,7 @@ function ComboboxPopup({
147148
alignOffset?: ComboboxPrimitive.Positioner.Props["alignOffset"];
148149
side?: ComboboxPrimitive.Positioner.Props["side"];
149150
anchor?: ComboboxPrimitive.Positioner.Props["anchor"];
151+
collisionAvoidance?: ComboboxPrimitive.Positioner.Props["collisionAvoidance"];
150152
}) {
151153
const { chipsRef, multiple } = React.use(ComboboxContext);
152154
const anchor = anchorProp ?? (multiple ? chipsRef : undefined);
@@ -157,6 +159,7 @@ function ComboboxPopup({
157159
align={align}
158160
alignOffset={alignOffset}
159161
anchor={anchor}
162+
collisionAvoidance={collisionAvoidance}
160163
className="z-[130] select-none"
161164
data-slot="combobox-positioner"
162165
side={side}

0 commit comments

Comments
 (0)