Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lbenie committed Mar 21, 2024
1 parent 82f1811 commit f73ab99
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions polaris-react/src/utilities/use-index-resource-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,26 @@ export function useIndexResourceState<T extends {[key: string]: unknown}>(
return newSelectedResources;
});
break;

case SelectionType.All:
case SelectionType.Page: {
const resourceList = resourceFilter
? resources.filter(resourceFilter)
: resources;
const mappedResources = new Set(resourceList.map(resourceIDResolver));

const hasRoomForMoreSelection =
isSelecting && selectedResources.size < resourceList.length;
const resourceIDs = new Set(resourceList.map(resourceIDResolver));

setSelectedResources(
hasRoomForMoreSelection ? resourceIDs : new Set(),
hasRoomForMoreSelection || isSelecting
? mappedResources
: new Set(),
);
setUnselectedResources(
hasRoomForMoreSelection ? new Set() : resourceIDs,
hasRoomForMoreSelection || isSelecting
? new Set()
: mappedResources,
);
break;
}
Expand Down

0 comments on commit f73ab99

Please sign in to comment.