Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Studio: open the user menu Help submenu upward (#12032)

Michael Han08571b94ef1d
diff --git a/studio/frontend/src/components/app-sidebar.tsx b/studio/frontend/src/components/app-sidebar.tsx
index 558144eb3f4..bb473219a94 100644
--- a/studio/frontend/src/components/app-sidebar.tsx
+++ b/studio/frontend/src/components/app-sidebar.tsx
@@ -5895,6 +5895,7 @@ export function AppSidebar() {
</DropdownMenuSubTrigger>
<DropdownMenuSubContent
{...accountSubmenuOffsets}
+ alignEnd={true}
className="unsloth-plus-menu sidebar-row-menu sidebar-menu w-56"
>
{HELP_GROUPS.map((group, index) => (
diff --git a/studio/frontend/src/components/ui/dropdown-menu.tsx b/studio/frontend/src/components/ui/dropdown-menu.tsx
index 5795775f431..066333595a5 100644
--- a/studio/frontend/src/components/ui/dropdown-menu.tsx
+++ b/studio/frontend/src/components/ui/dropdown-menu.tsx
@@ -269,12 +269,19 @@ function DropdownMenuSubTrigger({
function DropdownMenuSubContent({
className,
sideOffset,
+ alignOffset,
+ alignEnd,
style,
ref,
...props
-}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent>) {
+}: React.ComponentProps<typeof DropdownMenuPrimitive.SubContent> & {
+ /** Grow upward so the last item lines up with the trigger. */
+ alignEnd?: boolean;
+}) {
const isMobile = useIsMobile();
const [contentWidth, setContentWidth] = React.useState(0);
+ // Offset that brings the bottom edge level with the trigger.
+ const [endShift, setEndShift] = React.useState<number | null>(null);
const resizeObserverRef = React.useRef<ResizeObserver | null>(null);
const composedRef = React.useCallback(
(
@@ -288,13 +295,21 @@ function DropdownMenuSubContent({
if (!element) return;
snapRowInsets(element);
- const updateContentWidth = () => {
+ const updateContentSize = () => {
setContentWidth(element.offsetWidth);
+ const anchorHeight = Number.parseFloat(
+ getComputedStyle(element).getPropertyValue(
+ "--radix-popper-anchor-height",
+ ),
+ );
+ if (Number.isFinite(anchorHeight)) {
+ setEndShift(anchorHeight - element.offsetHeight);
+ }
};
- updateContentWidth();
+ updateContentSize();
if (typeof ResizeObserver !== "undefined") {
- resizeObserverRef.current = new ResizeObserver(updateContentWidth);
+ resizeObserverRef.current = new ResizeObserver(updateContentSize);
resizeObserverRef.current.observe(element);
}
},
@@ -310,6 +325,12 @@ function DropdownMenuSubContent({
const compactSideOffset =
isMobile && contentWidth > 0 ? -contentWidth : sideOffset;
+ const endAligned = alignEnd && !isMobile;
+ // With alignEnd, alignOffset applies from the bottom edge.
+ const resolvedAlignOffset =
+ endAligned && endShift !== null ? endShift - (alignOffset ?? 0) : alignOffset;
+ // Transparent, not hidden, while measuring: hidden content misses Radix's keyboard autofocus.
+ const measuring = endAligned && endShift === null;
return (
// Portaled like DropdownMenuContent: rendered inline, the fixed popper
// wrapper is a descendant of the parent menu's scroll container, so any
@@ -319,6 +340,7 @@ function DropdownMenuSubContent({
ref={composedRef}
data-slot="dropdown-menu-sub-content"
sideOffset={compactSideOffset}
+ alignOffset={resolvedAlignOffset}
style={{
...style,
visibility:
@@ -326,6 +348,8 @@ function DropdownMenuSubContent({
}}
className={cn(
"data-open:animate-in data-closed:animate-out data-closed:fade-out-0 data-open:fade-in-0 data-closed:zoom-out-95 data-open:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 bg-popover text-popover-foreground min-w-36 max-w-[calc(100vw-32px)] rounded-lg p-1 duration-100 z-50 origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden",
+ // !important so the fade-in animation cannot reveal it early.
+ measuring && "opacity-0!",
className,
)}
{...props}
diff --git a/tests/studio/test_compact_dropdown_submenus.py b/tests/studio/test_compact_dropdown_submenus.py
index a02b0d8254e..82403961f86 100644
--- a/tests/studio/test_compact_dropdown_submenus.py
+++ b/tests/studio/test_compact_dropdown_submenus.py
@@ -13,7 +13,7 @@ def test_shared_submenu_uses_its_layout_width_on_mobile():
assert 'import { useIsMobile } from "@/hooks/use-mobile";' in source
assert "element.offsetWidth" in source
assert "element.getBoundingClientRect().width" not in source
- assert "new ResizeObserver(updateContentWidth)" in source
+ assert "new ResizeObserver(updateContentSize)" in source
assert "isMobile && contentWidth > 0 ? -contentWidth : sideOffset" in source
assert "sideOffset={compactSideOffset}" in source
assert 'isMobile && contentWidth === 0 ? "hidden"' in source