1- import {
2- useClickAway ,
3- useCreation ,
4- useEventListener ,
5- useReactive ,
6- } from "ahooks" ;
1+ import { useClickAway , useCreation , useReactive } from "ahooks" ;
72import clsx from "clsx" ;
83import { isNil , noop } from "lodash-es" ;
94import { Copy , Link , SquareArrowOutUpRight } from "lucide-react" ;
@@ -15,6 +10,7 @@ import { useSearchStore } from "@/stores/searchStore";
1510import { copyToClipboard , OpenURLWithBrowser } from "@/utils" ;
1611import { isMac } from "@/utils/platform" ;
1712import { CONTEXT_MENU_PANEL_ID } from "@/constants" ;
13+ import { useShortcutsStore } from "@/stores/shortcutsStore" ;
1814
1915interface State {
2016 activeMenuIndex : number ;
@@ -36,6 +32,7 @@ const ContextMenu = ({ hideCoco }: ContextMenuProps) => {
3632 const setVisibleContextMenu = useSearchStore ( ( state ) => {
3733 return state . setVisibleContextMenu ;
3834 } ) ;
35+ const setOpenPopover = useShortcutsStore ( ( state ) => state . setOpenPopover ) ;
3936
4037 const selectedSearchContent = useSearchStore ( ( state ) => {
4138 return state . selectedSearchContent ;
@@ -157,11 +154,9 @@ const ContextMenu = ({ hideCoco }: ContextMenuProps) => {
157154 handleClick ( item ?. clickEvent ) ;
158155 } ) ;
159156
160- useEventListener ( "keydown" , ( event ) => {
161- if ( ! visibleContextMenu ) return ;
162-
163- event . stopImmediatePropagation ( ) ;
164- } ) ;
157+ useEffect ( ( ) => {
158+ setOpenPopover ( visibleContextMenu ) ;
159+ } , [ visibleContextMenu ] ) ;
165160
166161 const handleClick = ( click = noop ) => {
167162 click ?.( ) ;
0 commit comments