@@ -23,11 +23,11 @@ export function Search(): JSX.Element {
23
23
scope : scope || drive ,
24
24
} ) ;
25
25
const navigate = useNavigate ( ) ;
26
- const htmlElRef = useRef < HTMLDivElement | null > ( null ) ;
26
+ const resultsDiv = useRef < HTMLDivElement | null > ( null ) ;
27
27
28
28
function selectResult ( index : number ) {
29
29
setSelected ( index ) ;
30
- const currentElm = htmlElRef ?. current ?. children [ index ] ;
30
+ const currentElm = resultsDiv ?. current ?. children [ index ] ;
31
31
currentElm ?. scrollIntoView ( { block : 'nearest' } ) ;
32
32
}
33
33
@@ -36,7 +36,7 @@ export function Search(): JSX.Element {
36
36
e => {
37
37
e . preventDefault ( ) ;
38
38
const subject =
39
- htmlElRef ?. current ?. children [ selectedIndex ] ?. getAttribute ( 'about' ) ;
39
+ resultsDiv ?. current ?. children [ selectedIndex ] ?. getAttribute ( 'about' ) ;
40
40
41
41
if ( subject ) {
42
42
//@ts -ignore blur does exist though
@@ -80,9 +80,10 @@ export function Search(): JSX.Element {
80
80
}
81
81
82
82
return (
83
- < ContainerNarrow ref = { htmlElRef } >
84
- { error && < ErrorLook > { error . message } </ ErrorLook > }
85
- { query ?. length !== 0 && results . length !== 0 ? (
83
+ < ContainerNarrow >
84
+ { error ? (
85
+ < ErrorLook > { error . message } </ ErrorLook >
86
+ ) : query ?. length !== 0 && results . length !== 0 ? (
86
87
< >
87
88
< Heading >
88
89
< FaSearch />
@@ -91,15 +92,17 @@ export function Search(): JSX.Element {
91
92
< QueryText > { query } </ QueryText >
92
93
</ span >
93
94
</ Heading >
94
- { results . map ( ( subject , index ) => (
95
- < ResourceCard
96
- initialInView = { index < 5 }
97
- small
98
- subject = { subject }
99
- key = { subject }
100
- highlight = { index === selectedIndex }
101
- />
102
- ) ) }
95
+ < div ref = { resultsDiv } >
96
+ { results . map ( ( subject , index ) => (
97
+ < ResourceCard
98
+ initialInView = { index < 5 }
99
+ small
100
+ subject = { subject }
101
+ key = { subject }
102
+ highlight = { index === selectedIndex }
103
+ />
104
+ ) ) }
105
+ </ div >
103
106
</ >
104
107
) : (
105
108
< > { message } </ >
0 commit comments