Skip to content
TypeScript

fix(web): keep the project filter menu aligned with its trigger

Yash Singh115739c1e02e
diff --git a/apps/web/src/components/Sidebar.tsx b/apps/web/src/components/Sidebar.tsx
index c21191d88f5..868aa85cec6 100644
--- a/apps/web/src/components/Sidebar.tsx
+++ b/apps/web/src/components/Sidebar.tsx
@@ -1032,7 +1032,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
const projectScopeFilter = useComboboxFilter();
const allProjectSnapshotsReady = useAllEnvironmentProjectSnapshotsReady();
const allProjectConfigsReady = useAtomValue(environmentProjects.projectConfigsReadyAtom);
- const headerSearchRef = useRef<HTMLDivElement | null>(null);
// Safari may click after Ctrl+click opens settings; suppress that selection until the picker reopens.
const suppressNextScopeChangeRef = useRef(false);
const highlightedProjectScopeKeyRef = useRef<string | null>(null);
@@ -2990,7 +2989,6 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
fixedHeader={
<SidebarGroup className="z-[1]">
<SidebarThreadHeader
- searchFieldRef={headerSearchRef}
hasProjects={projectGroups.length > 0}
projectScope={
<Combobox
@@ -3061,8 +3059,8 @@ export default function Sidebar({ routeReveal }: { routeReveal: SidebarRouteReve
{/* Refocusing the trigger after a pointer close shows its focus ring and opens its tooltip. */}
<ComboboxPopup
align="start"
- anchor={headerSearchRef}
- className="max-w-[min(18rem,var(--available-width))] overflow-hidden"
+ collisionAvoidance={{ side: "flip", align: "shift" }}
+ className="w-[min(18rem,var(--available-width))] overflow-hidden"
finalFocus={(closeType) => closeType === "keyboard"}
>
<ComboboxSearchInput
diff --git a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
index bccbd38f86a..e400e03d275 100644
--- a/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
+++ b/apps/web/src/components/sidebar/SidebarThreadHeader.tsx
@@ -13,7 +13,6 @@ import { SidebarInput, SidebarMenuButton } from "../ui/sidebar";
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
export interface SidebarThreadHeaderProps {
- searchFieldRef?: RefObject<HTMLDivElement | null>;
hasProjects: boolean;
projectScope: ReactNode;
onNewProject: () => void;
@@ -33,7 +32,6 @@ export interface SidebarThreadHeaderProps {
}
export function SidebarThreadHeader({
- searchFieldRef,
hasProjects,
projectScope,
onNewProject,
@@ -60,10 +58,7 @@ export function SidebarThreadHeader({
return (
<div className="flex items-center gap-1">
- <div
- ref={searchFieldRef}
- 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"
- >
+ <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">
<SearchIcon className="size-4 shrink-0 text-(--sidebar-icon-color)" />
<SidebarInput
ref={searchInputRef}
diff --git a/apps/web/src/components/ui/combobox.tsx b/apps/web/src/components/ui/combobox.tsx
index a1db1108fa1..739eb15b9a0 100644
--- a/apps/web/src/components/ui/combobox.tsx
+++ b/apps/web/src/components/ui/combobox.tsx
@@ -139,6 +139,7 @@ function ComboboxPopup({
sideOffset = 4,
alignOffset,
align = "start",
+ collisionAvoidance,
anchor: anchorProp,
...props
}: ComboboxPrimitive.Popup.Props & {
@@ -147,6 +148,7 @@ function ComboboxPopup({
alignOffset?: ComboboxPrimitive.Positioner.Props["alignOffset"];
side?: ComboboxPrimitive.Positioner.Props["side"];
anchor?: ComboboxPrimitive.Positioner.Props["anchor"];
+ collisionAvoidance?: ComboboxPrimitive.Positioner.Props["collisionAvoidance"];
}) {
const { chipsRef, multiple } = React.use(ComboboxContext);
const anchor = anchorProp ?? (multiple ? chipsRef : undefined);
@@ -157,6 +159,7 @@ function ComboboxPopup({
align={align}
alignOffset={alignOffset}
anchor={anchor}
+ collisionAvoidance={collisionAvoidance}
className="z-[130] select-none"
data-slot="combobox-positioner"
side={side}