File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change 1
- import { ButtonHTMLAttributes , FC , useState , useMemo } from "react" ;
1
+ import {
2
+ ButtonHTMLAttributes ,
3
+ FC ,
4
+ useState ,
5
+ useMemo ,
6
+ useRef ,
7
+ useEffect ,
8
+ } from "react" ;
2
9
import { SelectOption } from "../../types" ;
3
10
import { AiFillCaretDown } from "react-icons/ai" ;
4
11
import { FiCheck } from "react-icons/fi" ;
@@ -24,6 +31,17 @@ const Select: FC<SelectProps> = ({
24
31
} ) => {
25
32
const [ isActive , setIsActive ] = useState < boolean > ( false ) ;
26
33
const [ filterText , setFilterText ] = useState < string > ( "" ) ;
34
+ const selectedRef = useRef < HTMLLIElement | null > ( null ) ;
35
+
36
+ useEffect (
37
+ ( ) =>
38
+ selectedRef . current ?. scrollIntoView ( {
39
+ block : "center" ,
40
+ inline : "start" ,
41
+ behavior : "smooth" ,
42
+ } ) ,
43
+ [ isActive , selected ]
44
+ ) ;
27
45
28
46
const filteredOptions = useMemo ( ( ) => {
29
47
if ( ! filter ) return [ ...options ] ;
@@ -87,6 +105,7 @@ const Select: FC<SelectProps> = ({
87
105
{ filteredOptions . length > 0 ? (
88
106
filteredOptions . map ( ( option , i ) => (
89
107
< li
108
+ ref = { option . value === selected . value ? selectedRef : undefined }
90
109
onClick = { ( ) => select ( option ) }
91
110
className = { cn (
92
111
"flex items-center gap-4 px-4 py-1.5 text-left text-sm hover:bg-gh-blue" ,
Original file line number Diff line number Diff line change @@ -188,7 +188,7 @@ class CardBuilder {
188
188
line += `${ encodeURI ( b . icon ) } ,${ encodeURI ( b . label ) } ,${ color } ;` ;
189
189
}
190
190
191
- this . url += line ;
191
+ this . url += ` ${ line } &` ;
192
192
}
193
193
194
194
return this ;
You can’t perform that action at this time.
0 commit comments