@@ -28,6 +28,7 @@ export interface SearchSelectProps extends React.HTMLAttributes<HTMLInputElement
2828 errorMessage ?: string ;
2929 enableClear ?: boolean ;
3030 children : React . ReactNode ;
31+ autoComplete ?: string ;
3132}
3233
3334const makeSelectClassName = makeClassName ( "SearchSelect" ) ;
@@ -50,9 +51,10 @@ const SearchSelect = React.forwardRef<HTMLInputElement, SearchSelectProps>((prop
5051 children,
5152 className,
5253 id,
54+ autoComplete = "off" ,
5355 ...other
5456 } = props ;
55- const comboboxButtonRef = useRef < HTMLButtonElement | null > ( null ) ;
57+ const comboboxInputRef = useRef < HTMLInputElement | null > ( null ) ;
5658
5759 const [ searchQuery , setSearchQuery ] = useInternalState ( "" , searchValue ) ;
5860 const [ selectedValue , setSelectedValue ] = useInternalState ( defaultValue , value ) ;
@@ -88,7 +90,7 @@ const SearchSelect = React.forwardRef<HTMLInputElement, SearchSelectProps>((prop
8890 < select
8991 title = "search-select-hidden"
9092 required = { required }
91- className = { tremorTwMerge ( "h-full w-full absolute left-0 top-0 z-0 opacity-0" ) }
93+ className = { tremorTwMerge ( "h-full w-full absolute left-0 top-0 -z-10 opacity-0" ) }
9294 value = { selectedValue }
9395 onChange = { ( e ) => {
9496 e . preventDefault ( ) ;
@@ -97,8 +99,8 @@ const SearchSelect = React.forwardRef<HTMLInputElement, SearchSelectProps>((prop
9799 disabled = { disabled }
98100 id = { id }
99101 onFocus = { ( ) => {
100- const comboboxButton = comboboxButtonRef . current ;
101- if ( comboboxButton ) comboboxButton . click ( ) ;
102+ const comboboxInput = comboboxInputRef . current ;
103+ if ( comboboxInput ) comboboxInput . focus ( ) ;
102104 } }
103105 >
104106 < option className = "hidden" value = "" disabled hidden >
@@ -131,7 +133,7 @@ const SearchSelect = React.forwardRef<HTMLInputElement, SearchSelectProps>((prop
131133 >
132134 { ( { value } ) => (
133135 < >
134- < Combobox . Button ref = { comboboxButtonRef } className = "w-full" >
136+ < Combobox . Button className = "w-full" >
135137 { Icon && (
136138 < span
137139 className = { tremorTwMerge (
@@ -153,6 +155,7 @@ const SearchSelect = React.forwardRef<HTMLInputElement, SearchSelectProps>((prop
153155 ) }
154156
155157 < Combobox . Input
158+ ref = { comboboxInputRef }
156159 className = { tremorTwMerge (
157160 // common
158161 "w-full outline-none text-left whitespace-nowrap truncate rounded-tremor-default focus:ring-2 transition duration-100 text-tremor-default pr-14 border py-2" ,
@@ -172,7 +175,7 @@ const SearchSelect = React.forwardRef<HTMLInputElement, SearchSelectProps>((prop
172175 setSearchQuery ( event . target . value ) ;
173176 } }
174177 displayValue = { ( value : string ) => valueToNameMapping . get ( value ) ?? "" }
175- autoComplete = "off"
178+ autoComplete = { autoComplete }
176179 />
177180 < div className = { tremorTwMerge ( "absolute inset-y-0 right-0 flex items-center pr-2.5" ) } >
178181 < ArrowDownHeadIcon
0 commit comments