diff --git a/docs/content.en/docs/release-notes/_index.md b/docs/content.en/docs/release-notes/_index.md index 6c5344d1..97f353ac 100644 --- a/docs/content.en/docs/release-notes/_index.md +++ b/docs/content.en/docs/release-notes/_index.md @@ -34,6 +34,7 @@ Information about release notes of Coco Server is provided here. - fix: tab key hides window in chat mode #641 - fix: arrow keys still navigated search when menu opened with Cmd+K #642 - fix: input lost when reopening dialog after search #644 +- fix: web page unmount event #645 ### ✈️ Improvements diff --git a/src/components/Search/ContextMenu.tsx b/src/components/Search/ContextMenu.tsx index 42cebe8d..da6888db 100644 --- a/src/components/Search/ContextMenu.tsx +++ b/src/components/Search/ContextMenu.tsx @@ -19,9 +19,7 @@ interface State { activeMenuIndex: number; } -interface ContextMenuProps { - hideCoco?: () => void; -} +interface ContextMenuProps {} const ContextMenu: FC = () => { const containerRef = useRef(null); diff --git a/src/components/Search/DropdownList.tsx b/src/components/Search/DropdownList.tsx index a931fae1..1a9d8039 100644 --- a/src/components/Search/DropdownList.tsx +++ b/src/components/Search/DropdownList.tsx @@ -6,7 +6,7 @@ import { MouseEvent, useMemo, } from "react"; -import { useDebounceFn, useUnmount } from "ahooks"; +import { useDebounceFn } from "ahooks"; import { useTranslation } from "react-i18next"; import { useSearchStore } from "@/stores/searchStore"; @@ -98,11 +98,6 @@ function DropdownList({ }; }, []); - useUnmount(() => { - setSelectedIndex(null); - setSelectedSearchContent(undefined); - }); - useEffect(() => { if (selectedIndex === null) { setSelectedSearchContent(undefined); @@ -150,6 +145,13 @@ function DropdownList({ initializeSelection(); }, [searchData]); + useEffect(() => { + return () => { + setSelectedIndex(null); + setSelectedSearchContent(undefined); + }; + }, []); + // Keyboard navigation useKeyboardNavigation({ suggests, diff --git a/src/components/Search/InputBox.tsx b/src/components/Search/InputBox.tsx index 723c5009..e4853424 100644 --- a/src/components/Search/InputBox.tsx +++ b/src/components/Search/InputBox.tsx @@ -46,7 +46,6 @@ interface ChatInputProps { }) => Promise; getFileMetadata: (path: string) => Promise; getFileIcon: (path: string, size: number) => Promise; - hideCoco?: () => void; hasModules?: string[]; searchPlaceholder?: string; chatPlaceholder?: string; diff --git a/src/components/Search/Search.tsx b/src/components/Search/Search.tsx index 841509d5..06035ca3 100644 --- a/src/components/Search/Search.tsx +++ b/src/components/Search/Search.tsx @@ -54,11 +54,10 @@ interface SearchProps { changeInput: (val: string) => void; isChatMode: boolean; input: string; - hideCoco?: () => void; setIsPinned?: (value: boolean) => void; } -function Search({ isChatMode, input, hideCoco, setIsPinned }: SearchProps) { +function Search({ isChatMode, input, setIsPinned }: SearchProps) { const mainWindowRef = useRef(null); return ( @@ -67,7 +66,7 @@ function Search({ isChatMode, input, hideCoco, setIsPinned }: SearchProps) {