Fix keyboard shortcuts leaked to multi-column mode

This commit is contained in:
Lim Chee Aun 2024-11-01 17:30:33 +08:00
parent f236ec5ab9
commit f0773dc6f3

View file

@ -30,10 +30,10 @@ function Shortcuts() {
if (!shortcuts.length) { if (!shortcuts.length) {
return null; return null;
} }
if ( const isMultiColumnMode =
settings.shortcutsViewMode === 'multi-column' || settings.shortcutsViewMode === 'multi-column' ||
(!settings.shortcutsViewMode && settings.shortcutsColumnsMode) (!settings.shortcutsViewMode && settings.shortcutsColumnsMode);
) { if (isMultiColumnMode) {
return null; return null;
} }
@ -87,16 +87,22 @@ function Shortcuts() {
.filter(Boolean); .filter(Boolean);
const navigate = useNavigate(); const navigate = useNavigate();
useHotkeys(['1', '2', '3', '4', '5', '6', '7', '8', '9'], (e, handler) => { useHotkeys(
const index = parseInt(handler.keys[0], 10) - 1; ['1', '2', '3', '4', '5', '6', '7', '8', '9'],
if (index < formattedShortcuts.length) { (e, handler) => {
const { path } = formattedShortcuts[index]; const index = parseInt(handler.keys[0], 10) - 1;
if (path) { if (index < formattedShortcuts.length) {
navigate(path); const { path } = formattedShortcuts[index];
menuRef.current?.closeMenu?.(); if (path) {
navigate(path);
menuRef.current?.closeMenu?.();
}
} }
} },
}); {
enabled: !isMultiColumnMode,
},
);
const [lists, setLists] = useState([]); const [lists, setLists] = useState([]);