ui : use a constant for the dropdown-menu search selector

Extract the '[data-slot="dropdown-menu-content"] input' focus selector into
a DROPDOWN_MENU_CONTENT_SEARCH_SELECTOR constant, alongside the existing
data-slot selector constant.

Assisted-by: llama-ui:Qwen3.8-Flash-Next
This commit is contained in:
Aleksander Grygier
2026-09-04 20:07:37 +02:00
parent 7144b70eb5
commit 75d95fa41c
2 changed files with 12 additions and 2 deletions
@@ -12,7 +12,11 @@
import type { ModelItem } from '$lib/components/app/navigation/utils';
import * as DropdownMenu from '$lib/components/ui/dropdown-menu';
import * as Tooltip from '$lib/components/ui/tooltip';
import { MODEL_SELECTOR_ICON, SETTINGS_KEYS } from '$lib/constants';
import {
DROPDOWN_MENU_CONTENT_SEARCH_SELECTOR,
MODEL_SELECTOR_ICON,
SETTINGS_KEYS
} from '$lib/constants';
import { KeyboardKey, ServerModelStatus } from '$lib/enums';
import { useModelParamsFallback } from '$lib/hooks/use-model-params-fallback.svelte';
import { useModelsSelector } from '$lib/hooks/use-models-selector.svelte';
@@ -56,7 +60,7 @@
if (!isOpen) return;
document
.querySelector<HTMLElement>('[data-slot="dropdown-menu-content"] input')
.querySelector<HTMLElement>(DROPDOWN_MENU_CONTENT_SEARCH_SELECTOR)
?.focus({ preventScroll: true });
});
}
@@ -23,6 +23,12 @@ export const DIALOG_SUBMENU_CONTENT = 'w-60';
export const CHAT_INPUT_FOCUS_SELECTOR =
'[data-slot="input-area"] textarea, [data-slot="input-area"] [contenteditable="true"]';
/**
* Selects the search input inside an open dropdown-menu's content, to focus it
* after the menu mounts (bits-ui's default auto-focus can yank page scroll).
*/
export const DROPDOWN_MENU_CONTENT_SEARCH_SELECTOR = '[data-slot="dropdown-menu-content"] input';
/** Default Tailwind size class for inline icon components (lucide, etc.). */
export const ICON_CLASS_DEFAULT = 'h-4 w-4';