import Block from '../Primitives/Block/Block' import { SearchInputV2 } from '../InputsV2/SearchInputV2' import type { MenuSearchProps } from './singleSelectV2.types' const SingleSelectV2Search = ({ enabled, hasItems, backgroundColor, searchPlaceholder, searchText, onSearchTextChange, searchInputRef, containerRef, }: MenuSearchProps) => { if (!enabled || !hasItems) return null return ( { onSearchTextChange(e.target.value) }} onKeyDown={(e) => { if (e.key === 'ArrowDown' || e.key === 'ArrowUp') { e.preventDefault() e.stopPropagation() const menuEl = e.currentTarget.closest( '[data-dropdown="dropdown"]' ) const first = menuEl?.querySelector( '[role="menuitem"]:not([data-disabled])' ) first?.focus() } }} autoFocus aria-label={searchPlaceholder ?? 'Search options'} /> ) } export default SingleSelectV2Search