diff --git a/src/pages/main/hooks/useCmdk.ts b/src/pages/main/hooks/useCmdk.ts index 6d683aaf..b0cee78b 100644 --- a/src/pages/main/hooks/useCmdk.ts +++ b/src/pages/main/hooks/useCmdk.ts @@ -300,7 +300,6 @@ export const useCmdk = ({ cmdkReferenceData, importProject }: IUseCmdk) => { [osType, cmdkReferenceData], ); useEffect(() => { - console.log("keydowneventlistnere added"); document.addEventListener("keydown", KeyDownEventListener); return () => document.removeEventListener("keydown", KeyDownEventListener); }, [KeyDownEventListener]); diff --git a/src/pages/main/hooks/useCmdkModal.ts b/src/pages/main/hooks/useCmdkModal.ts index 3069c77c..0a8ebc15 100644 --- a/src/pages/main/hooks/useCmdkModal.ts +++ b/src/pages/main/hooks/useCmdkModal.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from "react"; +import { useCallback, useEffect, useState } from "react"; import { useDispatch } from "react-redux"; @@ -9,6 +9,8 @@ import { setCurrentCmdkPage, } from "@_redux/main/cmdk"; import { useAppState } from "@_redux/useAppState"; +import { debounce } from "lodash"; +import { ShortDelay } from "@_constants/main"; export const useCmdkModal = () => { const dispatch = useDispatch(); @@ -19,8 +21,13 @@ export const useCmdkModal = () => { string | null | undefined >(); + const debouncedCmdkOpen = useCallback( + debounce(() => dispatch(setCmdkOpen(true)), ShortDelay), + [], + ); useEffect(() => { - cmdkPages.length && dispatch(setCmdkOpen(true)); + cmdkPages.length && debouncedCmdkOpen(); + // cmdkPages.length && dispatch(setCmdkOpen(true)); dispatch(setCurrentCmdkPage([...cmdkPages].pop() || "")); }, [cmdkPages]); useEffect(() => {