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.
Python agentaichatgptdeepseekfine-tuninggemmaimage-generationllamallmllmsopenaipythonqwenreinforcement-learningself-hostedstable-diffusiontext-to-speechttsuiunsloth
Studio: stop recipe dialogs opening a hint tooltip on open (#13668)
Keyi Yu72a45f7b6f84
diff --git a/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx b/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsxindex d6e1708862b..2505f1b9c9b 100644--- a/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx+++ b/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx@@ -5,6 +5,7 @@ import type { ComponentProps, ReactElement } from "react";import { DialogContent } from "@/components/ui/dialog";import { cn } from "@/lib/utils";+import { focusRecipeDialogOnOpen } from "./recipe-dialog-focus";/** A recipe dialog over the canvas. The overlay is clear, so the shadow is its edge: Firefox's* .scroll-rounded clip would cut it, so an inner viewport scrolls instead of the shadowed box. */@@ -12,6 +13,7 @@ export function RecipeDialogContent({className,viewportClassName,children,+ onOpenAutoFocus,...props}: ComponentProps<typeof DialogContent> & {viewportClassName?: string;@@ -25,6 +27,7 @@ export function RecipeDialogContent({"corner-squircle flex max-h-[min(calc(650px*var(--ui-space-scale,1)),calc(100dvh-var(--studio-window-chrome-top,0px)-2rem))] flex-col overflow-hidden p-0 sm:max-w-2xl shadow-border",className,)}+ onOpenAutoFocus={(event) => focusRecipeDialogOnOpen(event, onOpenAutoFocus)}{...props}><divdiff --git a/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-focus.ts b/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-focus.tsnew file mode 100644index 00000000000..57295020fc9--- /dev/null+++ b/studio/frontend/src/features/recipe-studio/dialogs/shared/recipe-dialog-focus.ts@@ -0,0 +1,22 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++type AutoFocusEvent = {+ defaultPrevented: boolean;+ preventDefault(): void;+ currentTarget: EventTarget | null;+};++/** Radix focuses the first tabbable on open, a FieldLabel hint whose tooltip opens on focus, so+ * focus the dialog itself; a caller's handler runs first and wins if it prevents the default. */+export function focusRecipeDialogOnOpen<E extends AutoFocusEvent>(+ event: E,+ onOpenAutoFocus?: (event: E) => void,+): void {+ onOpenAutoFocus?.(event);+ if (event.defaultPrevented) {+ return;+ }+ event.preventDefault();+ (event.currentTarget as HTMLElement | null)?.focus({ preventScroll: true });+}diff --git a/studio/frontend/tests/recipe-dialog-autofocus.test.ts b/studio/frontend/tests/recipe-dialog-autofocus.test.tsnew file mode 100644index 00000000000..02a877dd6ca--- /dev/null+++ b/studio/frontend/tests/recipe-dialog-autofocus.test.ts@@ -0,0 +1,69 @@+// SPDX-License-Identifier: AGPL-3.0-only+// Copyright 2026-present the Unsloth AI Inc. team. All rights reserved. See /studio/LICENSE.AGPL-3.0++import assert from "node:assert/strict";+import test from "node:test";++import { focusRecipeDialogOnOpen } from "../src/features/recipe-studio/dialogs/shared/recipe-dialog-focus.ts";+import { readSrc } from "./helpers/kit.ts";++const ROUTES_THROUGH_HELPER =+ /onOpenAutoFocus=\{\(event\) =>\s*focusRecipeDialogOnOpen\(event, onOpenAutoFocus\)\s*\}/;+const PROP_TAKEN_OUT_OF_SPREAD = /children,\s*onOpenAutoFocus,\s*\.\.\.props/;++function autoFocusEvent() {+ const focusCalls: unknown[] = [];+ const event = {+ defaultPrevented: false,+ preventDefault() {+ event.defaultPrevented = true;+ },+ currentTarget: {+ focus(options?: unknown) {+ focusCalls.push(options);+ },+ } as unknown as EventTarget,+ };+ return { event, focusCalls };+}++test("a recipe dialog focuses itself on open instead of its first hint button", () => {+ const { event, focusCalls } = autoFocusEvent();++ focusRecipeDialogOnOpen(event);++ assert.equal(event.defaultPrevented, true);+ assert.deepEqual(focusCalls, [{ preventScroll: true }]);+});++test("a caller's own open-focus handler runs first and keeps its choice", () => {+ const { event, focusCalls } = autoFocusEvent();+ let callerRan = false;++ focusRecipeDialogOnOpen(event, (received) => {+ assert.equal(received, event);+ callerRan = true;+ received.preventDefault();+ });++ assert.equal(callerRan, true);+ assert.deepEqual(focusCalls, []);+});++test("a caller's handler that leaves the default still gets the dialog focused", () => {+ const { event, focusCalls } = autoFocusEvent();+ let callerRan = false;++ focusRecipeDialogOnOpen(event, () => {+ callerRan = true;+ });++ assert.equal(callerRan, true);+ assert.deepEqual(focusCalls, [{ preventScroll: true }]);+});++test("every recipe dialog routes its open focus through the helper", () => {+ const source = readSrc("features/recipe-studio/dialogs/shared/recipe-dialog-content.tsx");+ assert.match(source, ROUTES_THROUGH_HELPER);+ assert.match(source, PROP_TAKEN_OUT_OF_SPREAD);+});