mirror of
https://github.com/appwrite/console.git
synced 2026-06-06 19:27:48 +00:00
fix: modifier keys triggering non modifier commands
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
};
|
||||
|
||||
export const toggleCommandCenter = () => {
|
||||
console.log('toggleCommandCenter');
|
||||
if (get(subPanels).length > 0) {
|
||||
clearSubPanels();
|
||||
} else {
|
||||
@@ -88,8 +89,8 @@
|
||||
}
|
||||
|
||||
const handleKeydown = (e) => {
|
||||
if (isInputEvent(e)) return;
|
||||
if (!$subPanels.length) {
|
||||
if (isInputEvent(e)) return;
|
||||
keys = [...keys, e.key].slice(-10);
|
||||
resetKeys();
|
||||
}
|
||||
|
||||
@@ -174,9 +174,13 @@ export const commandCenterKeyDownHandler = derived(
|
||||
|
||||
const { keys, ctrl: meta, shift, alt } = command;
|
||||
|
||||
const isMetaPressed = meta ? (isMac() ? event.metaKey : event.ctrlKey) : true;
|
||||
const isShiftPressed = shift ? event.shiftKey : true;
|
||||
const isAltPressed = alt ? event.altKey : true;
|
||||
const isMetaPressed = meta
|
||||
? isMac()
|
||||
? event.metaKey
|
||||
: event.ctrlKey
|
||||
: !(isMac() ? event.metaKey : event.ctrlKey);
|
||||
const isShiftPressed = shift ? event.shiftKey : !event.shiftKey;
|
||||
const isAltPressed = alt ? event.altKey : !event.altKey;
|
||||
|
||||
const commandKeyCodes = keys.map((key) => key.toUpperCase().charCodeAt(0));
|
||||
const allKeysPressed = recentKeyCodes.join('').includes(commandKeyCodes.join(''));
|
||||
|
||||
@@ -21,7 +21,10 @@
|
||||
if (search) {
|
||||
searchResults = [];
|
||||
executeSearch(search);
|
||||
} else searchResults = [];
|
||||
} else {
|
||||
searchResults = [];
|
||||
executeSearch.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
$: results = [
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
type Group = { type: 'group'; name: string };
|
||||
type IndexedOption = Option & { index: number };
|
||||
function isGroup(item: Option | Group): item is Group {
|
||||
return 'type' in item && item.type === 'group';
|
||||
return !!item && 'type' in item && item.type === 'group';
|
||||
}
|
||||
const getGroupsAndOptions = (options: Option[]) => {
|
||||
if (!options) return null;
|
||||
@@ -210,7 +210,7 @@
|
||||
if (isGroup(item)) return false;
|
||||
if (!item.nested) return false;
|
||||
|
||||
return !isGroup(prevItem) && !prevItem.nested;
|
||||
return !isGroup(prevItem) && !prevItem?.nested;
|
||||
};
|
||||
|
||||
const isLastNested = (index: number) => {
|
||||
@@ -219,7 +219,7 @@
|
||||
if (isGroup(item)) return false;
|
||||
if (!item.nested) return false;
|
||||
|
||||
return isGroup(nextItem) || !nextItem.nested;
|
||||
return isGroup(nextItem) || !nextItem?.nested;
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -5,12 +5,16 @@ export function debounce<F extends (...params: any[]) => void>(fn: F, delay: num
|
||||
timeoutID = window.setTimeout(() => fn.apply(this, args), delay) as unknown as ReturnType<
|
||||
typeof setTimeout
|
||||
>;
|
||||
} as F & { immediate: F };
|
||||
} as F & { immediate: F; cancel: () => void };
|
||||
|
||||
debounceFn.immediate = ((...args: Parameters<F>) => {
|
||||
clearTimeout(timeoutID);
|
||||
return fn(args);
|
||||
}) as F;
|
||||
|
||||
debounceFn.cancel = () => {
|
||||
clearTimeout(timeoutID);
|
||||
};
|
||||
|
||||
return debounceFn;
|
||||
}
|
||||
|
||||
+3
-1
@@ -21,7 +21,9 @@ const config = {
|
||||
}
|
||||
},
|
||||
vitePlugin: {
|
||||
inspector: true
|
||||
inspector: {
|
||||
toggleKeyCombo: 'meta-shift-i'
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user