mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-06 20:10:12 +02:00
add select all hotkey to lists
This commit is contained in:
@@ -44,6 +44,8 @@ import {
|
||||
import { ItemControls, ItemListHandle } from '/@/renderer/components/item-list/types';
|
||||
import { animationProps } from '/@/shared/components/animations/animation-props';
|
||||
import { useElementSize } from '/@/shared/hooks/use-element-size';
|
||||
import { useFocusWithin } from '/@/shared/hooks/use-focus-within';
|
||||
import { useHotkeys } from '/@/shared/hooks/use-hotkeys';
|
||||
import { useMergedRef } from '/@/shared/hooks/use-merged-ref';
|
||||
import { LibraryItem } from '/@/shared/types/domain-types';
|
||||
|
||||
@@ -288,7 +290,7 @@ const BaseItemGridList = ({
|
||||
const outerRef = useRef(null);
|
||||
const listRef = useRef<FixedSizeList<GridItemProps>>(null);
|
||||
const { ref: containerRef, width: containerWidth } = useElementSize();
|
||||
const containerFocusRef = useRef<HTMLDivElement | null>(null);
|
||||
const { focused, ref: containerFocusRef } = useFocusWithin();
|
||||
const handleRef = useRef<ItemListHandle | null>(null);
|
||||
const mergedContainerRef = useMergedRef(containerRef, rootRef, containerFocusRef);
|
||||
|
||||
@@ -654,6 +656,21 @@ const BaseItemGridList = ({
|
||||
|
||||
useImperativeHandle(ref, () => imperativeHandle, [imperativeHandle]);
|
||||
|
||||
useHotkeys([
|
||||
[
|
||||
'mod+a',
|
||||
() => {
|
||||
if (focused) {
|
||||
if (internalState.isAllSelected()) {
|
||||
internalState.deselectAll();
|
||||
} else {
|
||||
internalState.selectAll();
|
||||
}
|
||||
}
|
||||
},
|
||||
],
|
||||
]);
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className={styles.itemGridContainer}
|
||||
|
||||
Reference in New Issue
Block a user