1
- import React from "react" ;
1
+ import React , { MouseEvent } from "react" ;
2
2
import clsx from "clsx" ;
3
3
import { File } from "lucide-react" ;
4
4
@@ -7,6 +7,7 @@ import ListRight from "./ListRight";
7
7
import { useAppStore } from "@/stores/appStore" ;
8
8
import { useIsMobile } from "@/hooks/useIsMobile" ;
9
9
import type { SearchDocument } from "@/types/search" ;
10
+ import { useSearchStore } from "@/stores/searchStore" ;
10
11
11
12
interface SearchListItemProps {
12
13
item : SearchDocument ;
@@ -36,10 +37,23 @@ const SearchListItem: React.FC<SearchListItemProps> = React.memo(
36
37
37
38
const isMobile = useIsMobile ( ) ;
38
39
40
+ const { setSelectedSearchContent, setVisibleContextMenu } =
41
+ useSearchStore ( ) ;
42
+
43
+ const handleContextMenu = ( event : MouseEvent ) => {
44
+ event . preventDefault ( ) ;
45
+
46
+ setVisibleContextMenu ( true ) ;
47
+ } ;
48
+
39
49
return (
40
50
< div
41
51
ref = { itemRef }
42
- onMouseEnter = { onMouseEnter }
52
+ onMouseEnter = { ( ) => {
53
+ setSelectedSearchContent ( item ) ;
54
+
55
+ onMouseEnter ( ) ;
56
+ } }
43
57
onClick = { onItemClick }
44
58
className = { clsx (
45
59
"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(
51
65
role = "option"
52
66
aria-selected = { isSelected }
53
67
id = { `search-item-${ currentIndex } ` }
68
+ onContextMenu = { handleContextMenu }
54
69
>
55
70
< div
56
71
className = { `${
@@ -60,7 +75,12 @@ const SearchListItem: React.FC<SearchListItemProps> = React.memo(
60
75
} min-w-0 flex gap-2 items-center justify-start `}
61
76
>
62
77
< 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
+ ] }
64
84
item = { item }
65
85
itemIcon = { item ?. icon }
66
86
defaultIcon = { File }
0 commit comments