Skip to content

Commit

Permalink
prevent cmdk short keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmatthewnguyen105 committed Dec 14, 2023
1 parent 83be97b commit eb46131
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 31 deletions.
13 changes: 2 additions & 11 deletions src/components/main/stageView/iFrame/hooks/useCmdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@ export const useCmdk = ({
break; // Match found, exit the outer loop
}
}
// prevent chrome default short keys
if (
action === "Save" ||
action === "Download" ||
action === "Duplicate" ||
action === "Group" ||
action === "UnGroup"
) {
e.preventDefault();
}

if (isEditingRef.current) {
// for content-editing
if (
Expand Down Expand Up @@ -133,6 +122,8 @@ export const useCmdk = ({
dispatch(setCurrentCommand({ action }));
}
}

action && e.preventDefault();
},
[osType, cmdkReferenceData],
);
Expand Down
20 changes: 6 additions & 14 deletions src/pages/main/hooks/useCmdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -274,22 +274,14 @@ export const useCmdk = ({ cmdkReferenceData, importProject }: IUseCmdk) => {
break; // Match found, exit the outer loop
}
}
// prevent chrome default short keys
if (
action === "Save" ||
action === "Download" ||
action === "Duplicate" ||
action === "Group" ||
action === "UnGroup"
) {
e.preventDefault();
}

if (cmdkOpen) return;
if (action) {
LogAllow && console.log("action to be run by cmdk: ", action);
dispatch(setCurrentCommand({ action }));
if (!cmdkOpen) {
LogAllow && console.log("action to be run by cmdk: ", action);
dispatch(setCurrentCommand({ action }));
}
}

action && e.preventDefault();
},
[osType, cmdkOpen, cmdkReferenceData],
);
Expand Down
7 changes: 1 addition & 6 deletions src/pages/main/hooks/useCmdkModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,8 @@ export const useCmdkModal = () => {
string | null | undefined
>();

const debouncedCmdkOpen = useCallback(
debounce(() => dispatch(setCmdkOpen(true)), ShortDelay),
[],
);
useEffect(() => {
cmdkPages.length && debouncedCmdkOpen();
// cmdkPages.length && dispatch(setCmdkOpen(true));
cmdkPages.length && dispatch(setCmdkOpen(true));
dispatch(setCurrentCmdkPage([...cmdkPages].pop() || ""));
}, [cmdkPages]);
useEffect(() => {
Expand Down

0 comments on commit eb46131

Please sign in to comment.