Skip to content

Commit cb758ef

Browse files
authored
feat: context menu support for secondary pages (#680)
* feat: context menu support for secondary pages * docs: update changelog
1 parent 12b9b4b commit cb758ef

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Information about release notes of Coco Server is provided here.
1919
- feat: support right-click actions after text selection #624
2020
- feat: add ai overview minimum number of search results configuration #625
2121
- feat: add internationalized translations of AI-related extensions #632
22+
- feat: context menu support for secondary pages #680
2223

2324
### 🐛 Bug fix
2425

src/components/Search/SearchListItem.tsx

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from "react";
1+
import React, { MouseEvent } from "react";
22
import clsx from "clsx";
33
import { File } from "lucide-react";
44

@@ -7,6 +7,7 @@ import ListRight from "./ListRight";
77
import { useAppStore } from "@/stores/appStore";
88
import { useIsMobile } from "@/hooks/useIsMobile";
99
import type { SearchDocument } from "@/types/search";
10+
import { useSearchStore } from "@/stores/searchStore";
1011

1112
interface 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

Comments
 (0)