From 16eececfcfd9f1a4058e3ae75ba0677ed1206ea0 Mon Sep 17 00:00:00 2001 From: kricsleo Date: Sun, 3 Aug 2025 21:40:27 +0800 Subject: [PATCH] fix(Listbox): prevent autofocus to avoid breaking other focusable elements --- packages/core/src/Listbox/ListboxRoot.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/Listbox/ListboxRoot.vue b/packages/core/src/Listbox/ListboxRoot.vue index deabd2280..8ec3dc629 100644 --- a/packages/core/src/Listbox/ListboxRoot.vue +++ b/packages/core/src/Listbox/ListboxRoot.vue @@ -3,7 +3,7 @@ import type { PrimitiveProps } from '@/Primitive' import type { AcceptableValue, DataOrientation, Direction, FormFieldProps } from '@/shared/types' import { usePrimitiveElement } from '@/Primitive' import { getFocusIntent } from '@/RovingFocus/utils' -import { createContext, findValuesBetween, useDirection, useFormControl, useKbd, useTypeahead } from '@/shared' +import { createContext, findValuesBetween, getActiveElement, useDirection, useFormControl, useKbd, useTypeahead } from '@/shared' import { Primitive } from '..' type ListboxRootContext = { @@ -162,7 +162,7 @@ function changeHighlight(el: HTMLElement, scrollIntoView = true) { return highlightedElement.value = el - if (focusable.value) + if (focusable.value && currentElement.value?.contains(getActiveElement())) highlightedElement.value.focus() if (scrollIntoView) highlightedElement.value.scrollIntoView({ block: 'nearest' })