@@ -13,7 +13,7 @@ import {CodeContext} from './codeContext';
13
13
14
14
const KEYWORDS_REGEX = / \b _ _ _ (?: ( [ A - Z _ ] [ A - Z 0 - 9 _ ] * ) \. ) ? ( [ A - Z _ ] [ A - Z 0 - 9 _ ] * ) _ _ _ \b / g;
15
15
16
- function makeKeywordsClickable ( children : React . ReactChildren ) {
16
+ function makeKeywordsClickable ( children : React . ReactNode ) {
17
17
const items = Children . toArray ( children ) ;
18
18
19
19
KEYWORDS_REGEX . lastIndex = 0 ;
@@ -35,9 +35,10 @@ function makeKeywordsClickable(children: React.ReactChildren) {
35
35
}
36
36
arr . push (
37
37
< KeywordSelector
38
+ key = { lastIndex }
39
+ index = { lastIndex }
38
40
group = { match [ 1 ] || 'PROJECT' }
39
41
keyword = { match [ 2 ] }
40
- index = { lastIndex }
41
42
/>
42
43
) ;
43
44
lastIndex = KEYWORDS_REGEX . lastIndex ;
@@ -76,8 +77,8 @@ function KeywordSelector({keyword, group, index}: KeywordSelectorProps) {
76
77
const codeContext = useContext ( CodeContext ) ;
77
78
78
79
const [ isOpen , setIsOpen ] = useState ( false ) ;
79
- const [ referenceEl , setReferenceEl ] = useState ( null ) ;
80
- const [ dropdownEl , setDropdownEl ] = useState ( null ) ;
80
+ const [ referenceEl , setReferenceEl ] = useState < HTMLSpanElement > ( null ) ;
81
+ const [ dropdownEl , setDropdownEl ] = useState < HTMLElement > ( null ) ;
81
82
82
83
const { styles, state, attributes} = usePopper ( referenceEl , dropdownEl , {
83
84
placement : 'bottom' ,
@@ -90,7 +91,11 @@ function KeywordSelector({keyword, group, index}: KeywordSelectorProps) {
90
91
] ,
91
92
} ) ;
92
93
93
- useOnClickOutside ( { current : dropdownEl } , ( ) => isOpen && setIsOpen ( false ) ) ;
94
+ useOnClickOutside ( {
95
+ ref : { current : referenceEl } ,
96
+ enabled : isOpen ,
97
+ handler : ( ) => setIsOpen ( false ) ,
98
+ } ) ;
94
99
95
100
const [ sharedSelection , setSharedSelection ] = codeContext . sharedKeywordSelection ;
96
101
0 commit comments