Skip to content

Commit

Permalink
Don't use FLIP for large grids (#655)
Browse files Browse the repository at this point in the history
Signed-off-by: Carl Gieringer <78054+carlgieringer@users.noreply.github.com>
  • Loading branch information
carlgieringer authored Feb 20, 2024
1 parent 99547f4 commit 7e5c04e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion premiser-ui/src/components/itemGrid/ItemGrid.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ComponentId } from "@/types";
import { GridCell, GridCellProps } from "@react-md/utils";
import { Grid, GridCell, GridCellProps } from "@react-md/utils";
import React from "react";

import { FlipGrid } from "@/components/layout/FlipGrid";
Expand All @@ -17,6 +17,25 @@ export interface ItemGridProps {
* to show.
*/
export function ItemGrid({ id, items, itemColSpans, ...rest }: ItemGridProps) {
if (items.length > 64) {
// If there are a lot of items, the list takes a long time to render. Also
// there are weird behaviors when updating the list, like floating items
// above the list's normal position. So we use a regular grid for large
// lists.
//
// TODO(#221) see if there are more performant FLIP libraries
return (
<Grid id={id} {...rest}>
{items?.map((item) => {
return (
<GridCell key={item.key} {...itemColSpans}>
{item}
</GridCell>
);
})}
</Grid>
);
}
return (
<FlipGrid id={id} {...rest}>
{items?.map((item) => {
Expand Down

0 comments on commit 7e5c04e

Please sign in to comment.