forked from github/plane
fix: shortcut combination key bug fix (#733)
* fix: shortcut combination key bug fix * refactor: code refactor
This commit is contained in:
parent
a68d94c33f
commit
c093209338
@ -177,46 +177,48 @@ export const CommandPalette: React.FC = () => {
|
|||||||
|
|
||||||
const handleKeyDown = useCallback(
|
const handleKeyDown = useCallback(
|
||||||
(e: KeyboardEvent) => {
|
(e: KeyboardEvent) => {
|
||||||
|
const singleShortcutKeys = ["p", "v", "d", "h", "q", "m"];
|
||||||
|
const { key, ctrlKey, metaKey, altKey, shiftKey } = e;
|
||||||
|
const keyPressed = key.toLowerCase();
|
||||||
if (
|
if (
|
||||||
!(e.target instanceof HTMLTextAreaElement) &&
|
!(e.target instanceof HTMLTextAreaElement) &&
|
||||||
!(e.target instanceof HTMLInputElement) &&
|
!(e.target instanceof HTMLInputElement) &&
|
||||||
!(e.target as Element).classList?.contains("remirror-editor")
|
!(e.target as Element).classList?.contains("remirror-editor")
|
||||||
) {
|
) {
|
||||||
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "k") {
|
if ((ctrlKey || metaKey) && keyPressed === "k") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsPaletteOpen(true);
|
setIsPaletteOpen(true);
|
||||||
} else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "c") {
|
} else if ((ctrlKey || metaKey) && keyPressed === "c") {
|
||||||
if (e.altKey) {
|
if (altKey) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
copyIssueUrlToClipboard();
|
copyIssueUrlToClipboard();
|
||||||
}
|
}
|
||||||
} else if (e.key.toLowerCase() === "c") {
|
} else if (keyPressed === "c") {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsIssueModalOpen(true);
|
setIsIssueModalOpen(true);
|
||||||
} else if (e.key.toLowerCase() === "p") {
|
} else if ((ctrlKey || metaKey) && keyPressed === "b") {
|
||||||
e.preventDefault();
|
|
||||||
setIsProjectModalOpen(true);
|
|
||||||
} else if (e.key.toLowerCase() === "v") {
|
|
||||||
e.preventDefault();
|
|
||||||
setIsCreateViewModalOpen(true);
|
|
||||||
} else if (e.key.toLowerCase() === "d") {
|
|
||||||
e.preventDefault();
|
|
||||||
setIsCreateUpdatePageModalOpen(true);
|
|
||||||
} else if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === "b") {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
toggleCollapsed();
|
toggleCollapsed();
|
||||||
} else if (e.key.toLowerCase() === "h") {
|
} else if (key === "Delete") {
|
||||||
e.preventDefault();
|
|
||||||
setIsShortcutsModalOpen(true);
|
|
||||||
} else if (e.key.toLowerCase() === "q") {
|
|
||||||
e.preventDefault();
|
|
||||||
setIsCreateCycleModalOpen(true);
|
|
||||||
} else if (e.key.toLowerCase() === "m") {
|
|
||||||
e.preventDefault();
|
|
||||||
setIsCreateModuleModalOpen(true);
|
|
||||||
} else if (e.key === "Delete") {
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsBulkDeleteIssuesModalOpen(true);
|
setIsBulkDeleteIssuesModalOpen(true);
|
||||||
|
} else if (
|
||||||
|
singleShortcutKeys.includes(keyPressed) &&
|
||||||
|
(ctrlKey || metaKey || altKey || shiftKey)
|
||||||
|
) {
|
||||||
|
e.preventDefault();
|
||||||
|
} else if (keyPressed === "p") {
|
||||||
|
setIsProjectModalOpen(true);
|
||||||
|
} else if (keyPressed === "v") {
|
||||||
|
setIsCreateViewModalOpen(true);
|
||||||
|
} else if (keyPressed === "d") {
|
||||||
|
setIsCreateUpdatePageModalOpen(true);
|
||||||
|
} else if (keyPressed === "h") {
|
||||||
|
setIsShortcutsModalOpen(true);
|
||||||
|
} else if (keyPressed === "q") {
|
||||||
|
setIsCreateCycleModalOpen(true);
|
||||||
|
} else if (keyPressed === "m") {
|
||||||
|
setIsCreateModuleModalOpen(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user