@@ -38,13 +38,17 @@ export const Combobox: React.FC<ComboboxProps> = ({
3838 return flat ;
3939 } , [ options ] ) ;
4040
41+ // For filtering/search
42+ const [ query , setQuery ] = useState ( "" ) ;
43+
4144 const selectedOption = useMemo ( ( ) => {
4245 if ( ! value ) return null ;
43- return allOptionsFlat . find ( ( opt ) => getValue ( opt ) === value ) ?? null ;
44- } , [ value , allOptionsFlat ] ) ;
4546
46- // For filtering/search
47- const [ query , setQuery ] = useState ( "" ) ;
47+ const opt = allOptionsFlat . find ( ( opt ) => getValue ( opt ) === value ) ?? null ;
48+
49+ setQuery ( opt ? getLabel ( opt ) : "" ) ;
50+ return opt ;
51+ } , [ value , allOptionsFlat ] ) ;
4852
4953 const filteredOptions = useMemo ( ( ) => {
5054 if ( ! query ) return options ;
@@ -105,9 +109,9 @@ export const Combobox: React.FC<ComboboxProps> = ({
105109 ) }
106110 < ComboboxInput
107111 className = { `
108- w-full border border-surface-gray-2 rounded
112+ w-full bg-surface-gray-2 border border-surface-gray-2 rounded
109113 ${ selectedOption && getIcon ( selectedOption ) ? "pl-8" : "pl-2" }
110- pr-2 py-1 min-h-[25px] text-base bg-surface-white
114+ pr-2 py-1 min-h-[25px] text-base
111115 placeholder-ink-gray-4 text-ink-gray-8
112116 outline-none focus:border-outline-gray-4 focus:ring-2 focus:ring-outline-gray-3
113117 transition-colors
@@ -144,7 +148,7 @@ export const Combobox: React.FC<ComboboxProps> = ({
144148 { filteredOptions . map ( ( opt ) =>
145149 typeof opt === "object" && "group" in opt ? (
146150 < div key = { opt . group } >
147- < div className = "px -2 py-1 text-xs text-ink-gray-5 font-semibold bg-surface-gray-2 " >
151+ < div className = "p -2 text-xs text-ink-gray-5 font-semibold" >
148152 { opt . group }
149153 </ div >
150154 { opt . options . map ( ( option ) => (
@@ -167,7 +171,7 @@ export const Combobox: React.FC<ComboboxProps> = ({
167171 < span className = "flex-1" > { getLabel ( option ) } </ span >
168172 { selectedOption &&
169173 getValue ( option ) === getValue ( selectedOption ) && (
170- < span className = "ml-2 text-green-600 " >
174+ < span className = "ml-2 text-ink-gray-5 " >
171175 < svg width = "16" height = "16" viewBox = "0 0 16 16" >
172176 < path
173177 d = "M4 8l3 3 5-5"
@@ -202,7 +206,7 @@ export const Combobox: React.FC<ComboboxProps> = ({
202206 { selectedOption &&
203207 getValue ( opt as SimpleOption ) ===
204208 getValue ( selectedOption ) && (
205- < span className = "ml-2 text-green-600 " >
209+ < span className = "ml-2 text-ink-gray-5 " >
206210 < svg width = "16" height = "16" viewBox = "0 0 16 16" >
207211 < path
208212 d = "M4 8l3 3 5-5"
0 commit comments