@@ -24,7 +24,6 @@ export default function CategorySelector({
2424 categories = defaultCategories ,
2525} : CategorySelectorProps ) {
2626 const [ isOpen , setIsOpen ] = useState ( false ) ;
27- const [ searchQuery , setSearchQuery ] = useState ( "" ) ;
2827 const dropdownRef = useRef < HTMLDivElement > ( null ) ;
2928 const [ portalRoot , setPortalRoot ] = useState < HTMLElement | null > ( null ) ;
3029 const portalDropdownRef = useRef < HTMLDivElement > ( null ) ;
@@ -62,12 +61,9 @@ export default function CategorySelector({
6261 } ;
6362 } , [ isOpen ] ) ;
6463
65- const filteredCategories = categories . filter ( ( cat ) => cat . toLowerCase ( ) . includes ( searchQuery . toLowerCase ( ) ) ) ;
66-
6764 const handleCategorySelect = ( category : string ) => {
6865 onCategoryChange ( category ) ;
6966 setIsOpen ( false ) ;
70- setSearchQuery ( "" ) ;
7167 } ;
7268
7369 const handleRemoveCategory = ( e : React . MouseEvent ) => {
@@ -107,78 +103,46 @@ export default function CategorySelector({
107103 createPortal (
108104 < div
109105 ref = { portalDropdownRef }
110- className = " top-full left-0 right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 z-[999999] max-h-[400px] overflow-hidden"
106+ className = "top-full left-0 right-0 mt-2 bg-white rounded-lg shadow-lg border border-gray-200 z-[999999] max-h-[400px] overflow-hidden"
111107 style = { {
112108 position : "absolute" ,
113109 top : coords . top ,
114110 left : coords . left ,
115111 width : coords . width ,
116112 } }
117113 >
118- { /* Search Input */ }
119- < div className = "p-4 border-b border-gray-200" >
120- < input
121- type = "text"
122- placeholder = "Select an option or create one"
123- value = { searchQuery }
124- onChange = { ( e ) => setSearchQuery ( e . target . value ) }
125- className = "w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-purple-500 text-sm"
126- autoFocus
127- />
128- </ div >
129-
130114 { /* Category List */ }
131115 < div className = "overflow-y-auto max-h-[300px]" >
132- { filteredCategories . length > 0 ? (
133- filteredCategories . map ( ( category ) => (
134- < div
135- key = { category }
136- onClick = { ( ) => handleCategorySelect ( category ) }
137- className = "flex items-center gap-3 px-4 py-3 hover:bg-gray-50 cursor-pointer transition-colors"
138- >
139- { /* Drag Handle */ }
140- < div className = "flex flex-col gap-[2px]" >
141- < div className = "flex gap-[2px]" >
142- < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
143- < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
144- </ div >
145- < div className = "flex gap-[2px]" >
146- < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
147- < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
148- </ div >
149- < div className = "flex gap-[2px]" >
150- < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
151- < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
152- </ div >
116+ { categories . map ( ( category ) => (
117+ < div
118+ key = { category }
119+ onClick = { ( ) => handleCategorySelect ( category ) }
120+ className = "flex items-center gap-3 px-4 py-3 hover:bg-gray-50 cursor-pointer transition-colors"
121+ >
122+ { /* Drag Handle */ }
123+ < div className = "flex flex-col gap-[2px]" >
124+ < div className = "flex gap-[2px]" >
125+ < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
126+ < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
153127 </ div >
154-
155- { /* Category */ }
156- < span
157- className = { `px-3 py-1 rounded-md text-sm font-medium ${ defaultCategoryColors [ category ] || "bg-gray-100 text-gray-700" } ` }
158- >
159- { category }
160- </ span >
161- </ div >
162- ) )
163- ) : (
164- < div className = "px-4 py-8 text-center text-gray-500 text-sm" >
165- { searchQuery ? (
166- < div >
167- < p > No matching categories</ p >
168- < button
169- onClick = { ( ) => {
170- handleCategorySelect ( searchQuery ) ;
171- } }
172- className = "mt-2 text-purple-600 hover:text-purple-700 font-medium"
173- >
174- Create "{ searchQuery } "
175- </ button >
128+ < div className = "flex gap-[2px]" >
129+ < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
130+ < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
131+ </ div >
132+ < div className = "flex gap-[2px]" >
133+ < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
134+ < div className = "w-1 h-1 bg-gray-400 rounded-full" > </ div >
176135 </ div >
177- ) : (
178- "No categories available"
179- ) }
136+ </ div >
137+
138+ { /* Category */ }
139+ < span
140+ className = { `px-3 py-1 rounded-md text-sm font-medium ${ defaultCategoryColors [ category ] || "bg-gray-100 text-gray-700" } ` }
141+ >
142+ { category }
143+ </ span >
180144 </ div >
181- ) }
145+ ) ) }
182146 </ div >
183147 </ div > ,
184148 portalRoot
0 commit comments