Skip to content

Commit

Permalink
Masonry: Fix multi-column issues (#3564)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyenwei committed May 13, 2024
1 parent 1e2ee9e commit 734d7e3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions packages/gestalt/src/Masonry/defaultTwoColumnModuleLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,12 +613,12 @@ const defaultTwoColumnModuleLayout = <T: { +[string]: mixed }>({
const batchSize = multiColumnItems.length;
const batches = Array.from({ length: batchSize }, (): $ReadOnlyArray<T> => []).map(
(batch, i) => {
const startIndex = i === 0 ? 0 : items.indexOf(multiColumnItems[i]);
const startIndex = i === 0 ? 0 : itemsWithoutPositions.indexOf(multiColumnItems[i]);
const endIndex =
i + 1 === multiColumnItems.length
? items.length
: items.indexOf(multiColumnItems[i + 1]);
return items.slice(startIndex, endIndex);
? itemsWithoutPositions.length
: itemsWithoutPositions.indexOf(multiColumnItems[i + 1]);
return itemsWithoutPositions.slice(startIndex, endIndex);
},
);
const { positions: paintedItemPositions, heights: paintedItemHeights } =
Expand Down
2 changes: 1 addition & 1 deletion packages/gestalt/src/MasonryV2.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ function useLayout<T: { +[string]: mixed }>({
items
.filter((item) => item && !positionStore.has(item))
.some((item) => typeof item.columnSpan === 'number' && item.columnSpan > 1);
const itemToMeasureCount = hasMultiColumnItems ? MULTI_COL_ITEMS_MEASURE_BATCH_SIZE : minCols;
const itemToMeasureCount = hasMultiColumnItems ? MULTI_COL_ITEMS_MEASURE_BATCH_SIZE + 1 : minCols;
const layoutFunction = getLayoutAlgorithm({
columnWidth,
gutter,
Expand Down

0 comments on commit 734d7e3

Please sign in to comment.