mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-02 06:06:41 +01:00
Fix keyboard shortcuts leaked to multi-column mode
This commit is contained in:
parent
f236ec5ab9
commit
f0773dc6f3
1 changed files with 18 additions and 12 deletions
|
@ -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([]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue