1- import React from "react" ;
1+ import React , { MouseEvent } from "react" ;
22import clsx from "clsx" ;
33import { File } from "lucide-react" ;
44
@@ -7,6 +7,7 @@ import ListRight from "./ListRight";
77import { useAppStore } from "@/stores/appStore" ;
88import { useIsMobile } from "@/hooks/useIsMobile" ;
99import type { SearchDocument } from "@/types/search" ;
10+ import { useSearchStore } from "@/stores/searchStore" ;
1011
1112interface SearchListItemProps {
1213 item : SearchDocument ;
@@ -36,10 +37,23 @@ const SearchListItem: React.FC<SearchListItemProps> = React.memo(
3637
3738 const isMobile = useIsMobile ( ) ;
3839
40+ const { setSelectedSearchContent, setVisibleContextMenu } =
41+ useSearchStore ( ) ;
42+
43+ const handleContextMenu = ( event : MouseEvent ) => {
44+ event . preventDefault ( ) ;
45+
46+ setVisibleContextMenu ( true ) ;
47+ } ;
48+
3949 return (
4050 < div
4151 ref = { itemRef }
42- onMouseEnter = { onMouseEnter }
52+ onMouseEnter = { ( ) => {
53+ setSelectedSearchContent ( item ) ;
54+
55+ onMouseEnter ( ) ;
56+ } }
4357 onClick = { onItemClick }
4458 className = { clsx (
4559 "w-full px-2 py-2.5 text-sm flex mb-0 flex-row items-center mobile:mb-2 mobile:flex-col mobile:items-start justify-between rounded-lg transition-colors cursor-pointer text-[#333] dark:text-[#d8d8d8]" ,
@@ -51,6 +65,7 @@ const SearchListItem: React.FC<SearchListItemProps> = React.memo(
5165 role = "option"
5266 aria-selected = { isSelected }
5367 id = { `search-item-${ currentIndex } ` }
68+ onContextMenu = { handleContextMenu }
5469 >
5570 < div
5671 className = { `${
@@ -60,7 +75,12 @@ const SearchListItem: React.FC<SearchListItemProps> = React.memo(
6075 } min-w-0 flex gap-2 items-center justify-start `}
6176 >
6277 < CommonIcon
63- renderOrder = { [ "special_icon" , "item_icon" , "connector_icon" , "default_icon" ] }
78+ renderOrder = { [
79+ "special_icon" ,
80+ "item_icon" ,
81+ "connector_icon" ,
82+ "default_icon" ,
83+ ] }
6484 item = { item }
6585 itemIcon = { item ?. icon }
6686 defaultIcon = { File }
0 commit comments