fix list select all hotkey (#2195)

This commit is contained in:
jeffvli
2026-07-05 21:01:24 -07:00
parent 2ad4c58dcd
commit 7b5df97fa0
17 changed files with 189 additions and 87 deletions
@@ -343,6 +343,7 @@ export interface ItemGridListProps {
gap?: 'lg' | 'md' | 'sm' | 'xl' | 'xs';
getItem?: (index: number) => ItemCardProps['data'];
getItemIndex?: (rowId: string) => number | undefined;
getLoadedItems?: () => unknown[];
getRowId?: ((item: unknown) => string) | string;
initialTop?: {
to: number;
@@ -372,6 +373,7 @@ const BaseItemGridList = ({
gap = 'sm',
getItem,
getItemIndex,
getLoadedItems,
getRowId,
initialTop,
itemCount,
@@ -401,9 +403,18 @@ const BaseItemGridList = ({
[data, getItem],
);
const dataRef = useRef(data);
const getLoadedItemsRef = useRef(getLoadedItems);
dataRef.current = data;
getLoadedItemsRef.current = getLoadedItems;
const getDataFn = useCallback(() => {
return data;
}, [data]);
const loadedItems = getLoadedItemsRef.current?.();
if (loadedItems?.length) {
return loadedItems;
}
return dataRef.current ?? [];
}, []);
const extractRowId = useMemo(() => createExtractRowId(getRowId), [getRowId]);
@@ -782,6 +793,7 @@ const BaseItemGridList = ({
useListHotkeys({
controls,
focusContainerRef: rootRef,
focused,
internalState,
itemType,