@@ -130,7 +130,6 @@ export const DocumentList: React.FC<DocumentListProps> = ({
130130 // set first select hover
131131 if ( from === 0 && list . length > 0 ) {
132132 setSelectedItem ( 0 ) ;
133- getDocDetail ( list [ 0 ] ?. document ) ;
134133 }
135134
136135 if ( taskId === taskIdRef . current ) {
@@ -193,12 +192,11 @@ export const DocumentList: React.FC<DocumentListProps> = ({
193192 ) ;
194193
195194 const onMouseEnter = useCallback (
196- ( index : number , item : any ) => {
195+ ( index : number ) => {
197196 if ( isKeyboardMode ) return ;
198- getDocDetail ( item ) ;
199197 setSelectedItem ( index ) ;
200198 } ,
201- [ isKeyboardMode , getDocDetail ]
199+ [ isKeyboardMode ]
202200 ) ;
203201
204202 useEffect ( ( ) => {
@@ -236,7 +234,6 @@ export const DocumentList: React.FC<DocumentListProps> = ({
236234 ? Math . max ( 0 , prev - 1 )
237235 : Math . min ( data . list . length - 1 , prev + 1 ) ;
238236
239- getDocDetail ( data . list [ nextIndex ] ?. document ) ;
240237 itemRefs . current [ nextIndex ] ?. scrollIntoView ( {
241238 behavior : "smooth" ,
242239 block : "nearest" ,
@@ -284,6 +281,14 @@ export const DocumentList: React.FC<DocumentListProps> = ({
284281 } ;
285282 } , [ handleKeyDown , handleMouseMove ] ) ;
286283
284+ useEffect ( ( ) => {
285+ if ( selectedItem === null ) return ;
286+ const doc = data . list [ selectedItem ] ?. document ;
287+ if ( doc ) {
288+ getDocDetail ( doc ) ;
289+ }
290+ } , [ selectedItem , data , getDocDetail ] ) ;
291+
287292 return (
288293 < div
289294 className = { `border-r border-gray-200 dark:border-gray-700 flex flex-col h-full overflow-x-hidden ${
@@ -298,10 +303,7 @@ export const DocumentList: React.FC<DocumentListProps> = ({
298303 />
299304 </ div >
300305
301- < Scrollbar
302- className = "flex-1 overflow-auto pr-0.5"
303- ref = { containerRef }
304- >
306+ < Scrollbar className = "flex-1 overflow-auto pr-0.5" ref = { containerRef } >
305307 { data ?. list && data . list . length > 0 && (
306308 < div >
307309 { data . list . map ( ( hit , index ) => (
@@ -311,7 +313,7 @@ export const DocumentList: React.FC<DocumentListProps> = ({
311313 item = { { ...hit . document , querySource : hit . source } }
312314 isSelected = { selectedItem === index }
313315 currentIndex = { index }
314- onMouseEnter = { ( ) => onMouseEnter ( index , hit . document ) }
316+ onMouseEnter = { ( ) => onMouseEnter ( index ) }
315317 onItemClick = { ( ) => {
316318 platformAdapter . openSearchItem ( hit . document , formatUrl ) ;
317319 } }
0 commit comments