Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Sidebar: cap the + menu by the sidebar's active max width

AdityaUmalefc4f69675735
diff --git a/src/components/Sidebar.plus-menu.test.ts b/src/components/Sidebar.plus-menu.test.ts
index ea412a652b..a2e3414881 100644
--- a/src/components/Sidebar.plus-menu.test.ts
+++ b/src/components/Sidebar.plus-menu.test.ts
@@ -94,7 +94,16 @@ describe("the sidebar's + menu with a long bot name (simple mode)", () => {
it("keeps the right-anchored menu no wider than the sidebar, so it can't run off the left edge", () => {
const menu = withLongBot().find((node) => node.props.role === "menu")!;
expect(menu.props.className).toContain("right-0");
- expect(menu.props.className).toContain("md:max-w-[calc(var(--sidebar-width)_-_48px)]");
+ expect(menu.props.className).toContain("md:max-w-[calc(min(var(--sidebar-width),var(--sidebar-max))_-_48px)]");
+ });
+
+ it("caps the menu by the sidebar's own cap, which is narrower than a saved width while a side panel is open", () => {
+ const root = (state: Record<string, unknown>) => openPlusMenu(true, false, state).find((node) => node.type === "aside")!;
+ const style = (state: Record<string, unknown>) => root(state).props.style as Record<string, string>;
+ expect(style({ computerOpen: true })["--sidebar-max"]).toBe("280px");
+ expect(style({ inspectorOpen: true })["--sidebar-max"]).toBe("280px");
+ expect(style({})["--sidebar-max"]).toBe("calc(100vw - 320px)");
+ expect(root({ computerOpen: true }).props.className).toContain("md:max-w-[var(--sidebar-max)]");
});
it("truncates the bot's name in New conversation with … and keeps the full name on hover", () => {
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 830c94734c..62fdf8510d 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1163,7 +1163,7 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
<>
<div role="menu" aria-label={remoteClient ? t("sidebar.new") : t("sidebar.newOrShare")} onKeyDown={navigateThreadMenu} className={cn(
"absolute z-40 w-max min-w-[200px] overflow-hidden", MENU_SHEET,
- rail ? "left-full top-0 ml-4" : cn("top-full", advanced ? "mt-1" : "mt-1.5", density === "icons" ? "left-0" : "right-0 md:max-w-[calc(var(--sidebar-width)_-_48px)]"),
+ rail ? "left-full top-0 ml-4" : cn("top-full", advanced ? "mt-1" : "mt-1.5", density === "icons" ? "left-0" : "right-0 md:max-w-[calc(min(var(--sidebar-width),var(--sidebar-max))_-_48px)]"),
plusMotion.className,
)} {...plusMotion.exitProps}>
{advanced && <button
@@ -1245,12 +1245,12 @@ export const Sidebar = memo(function Sidebar({ open, onClose, collapseToIcons =
// The phone's list covers the whole screen: choosing the bot that is already open has to dismiss it too.
if (phone && open && event.target instanceof Element && !(event.target instanceof HTMLInputElement) && event.target.closest("[data-sidebar-bot-row], [data-sidebar-hero]")) onClose();
}}
- style={{ "--sidebar-width": `${sizing.width}px` } as CSSProperties}
+ style={{ "--sidebar-width": `${sizing.width}px`, "--sidebar-max": sidePanelOpen ? advanced ? "320px" : "280px" : "calc(100vw - 320px)" } as CSSProperties}
className={cn(
"relative flex h-full shrink-0 flex-col border-r-[0.5px] border-edge bg-panel max-md:[--scroll-fade-surface:var(--color-app)]",
sizing.resizing && !sizing.snapping ? "transition-none" : "transition-[width] duration-200 motion-reduce:transition-none",
density === "icons" ? rail ? "w-[92px]" : "w-[80px]" : advanced ? "w-[320px] md:w-[var(--sidebar-width)]" : "w-[280px] md:w-[var(--sidebar-width)]",
- sidePanelOpen ? advanced ? "md:max-w-[320px]" : "md:max-w-[280px]" : "md:max-w-[calc(100vw-320px)]",
+ "md:max-w-[var(--sidebar-max)]",
// max-md: rather than an md: cancel: Tailwind v4 emits the native `translate`, and any value but `none` makes
// this a containing block for its `fixed` descendants.
"max-md:absolute max-md:inset-y-0 max-md:left-0 max-md:z-40 max-md:w-full max-md:bg-app",