Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { useRef } from 'react';
import React, { useRef, useEffect } from 'react';
import type { ListRowRenderer } from 'react-virtualized';
import { List as VirtualizedList, CellMeasurer, CellMeasurerCache } from 'react-virtualized';
import { css } from '@emotion/react';
Expand Down Expand Up @@ -51,9 +51,16 @@ export const GridColumn = ({
})
);

// Reset the row measurement cache when the list changes
useEffect(() => {
if (rowMeasurementCache.current) {
rowMeasurementCache.current.clearAll();
}
}, [list]);

if (isLoading) {
return (
<EuiFlexGrid gutterSize="l" columns={3} alignItems="start">
<EuiFlexGrid gutterSize="m" columns={3} alignItems="start">
{Array.from({ length: 12 }).map((_, index) => (
<EuiFlexItem key={index} grow={3}>
<EuiSkeletonRectangle height="160px" width="100%" />
Expand All @@ -66,7 +73,7 @@ export const GridColumn = ({
if (!list.length) {
return (
<EuiFlexGrid
gutterSize="l"
gutterSize="m"
columns={3}
data-test-subj="emptyState"
style={emptyStateStyles}
Expand Down Expand Up @@ -105,12 +112,13 @@ export const GridColumn = ({
>
{({ registerChild }) => (
<div ref={registerChild} style={style}>
<EuiFlexGrid columns={3} gutterSize="l" alignItems="start">
<EuiFlexGrid columns={3} gutterSize="m" alignItems="start">
{items.map((item) => (
<EuiFlexItem
key={item.id}
// Ensure that cards wrapped in EuiTours/EuiPopovers correctly inherit the full grid row height
css={css`
align-self: stretch;
& > .euiPopover,
& > .euiPopover > .euiCard {
height: 100%;
Expand Down Expand Up @@ -144,9 +152,7 @@ export const GridColumn = ({
}}
>
{({ height, isScrolling, onChildScroll, scrollTop }) => (
// `key` is a hack to re-render the list when the number of items changes, see:
// https://stackoverflow.com/questions/52769760/react-virtualized-list-item-does-not-re-render-with-changed-props-until-i-scroll
<EuiAutoSizer disableHeight key={list.length}>
<EuiAutoSizer disableHeight>
{({ width }) => (
<VirtualizedList
tabIndex={-1}
Expand Down
Loading