Fix rendering of sub groups in group tiles

This commit is contained in:
Mitchell McCaffrey 2021-05-21 16:14:11 +10:00
parent f496adae1d
commit 549ecbf65a
2 changed files with 14 additions and 6 deletions

View File

@ -14,7 +14,11 @@ import SortableTiles from "../drag/SortableTiles";
import useResponsiveLayout from "../../hooks/useResponsiveLayout"; import useResponsiveLayout from "../../hooks/useResponsiveLayout";
import { groupsFromIds, itemsFromGroups } from "../../helpers/select"; import {
groupsFromIds,
itemsFromGroups,
getGroupItems,
} from "../../helpers/select";
function MapTiles({ function MapTiles({
maps, maps,
@ -90,13 +94,12 @@ function MapTiles({
); );
} else { } else {
const isSelected = selectedGroupIds.includes(group.id); const isSelected = selectedGroupIds.includes(group.id);
const items = getGroupItems(group);
return ( return (
<MapTileGroup <MapTileGroup
key={group.id} key={group.id}
group={group} group={group}
maps={group.items.map((item) => maps={items.map((item) => maps.find((map) => map.id === item.id))}
maps.find((map) => map.id === item.id)
)}
isSelected={isSelected} isSelected={isSelected}
onSelect={onTileSelect} onSelect={onTileSelect}
/> />

View File

@ -15,7 +15,11 @@ import SortableTiles from "../drag/SortableTiles";
import useResponsiveLayout from "../../hooks/useResponsiveLayout"; import useResponsiveLayout from "../../hooks/useResponsiveLayout";
import { groupsFromIds, itemsFromGroups } from "../../helpers/select"; import {
groupsFromIds,
itemsFromGroups,
getGroupItems,
} from "../../helpers/select";
function TokenTiles({ function TokenTiles({
tokens, tokens,
@ -70,11 +74,12 @@ function TokenTiles({
); );
} else { } else {
const isSelected = selectedGroupIds.includes(group.id); const isSelected = selectedGroupIds.includes(group.id);
const items = getGroupItems(group);
return ( return (
<TokenTileGroup <TokenTileGroup
key={group.id} key={group.id}
group={group} group={group}
tokens={group.items.map((item) => tokens={items.map((item) =>
tokens.find((token) => token.id === item.id) tokens.find((token) => token.id === item.id)
)} )}
isSelected={isSelected} isSelected={isSelected}