vaadin / react-components

15 stars 4 forks source link

Grid column auto-width doesn't work with async loaded data #215

Closed sissbruecker closed 10 months ago

sissbruecker commented 10 months ago

When loading data asynchronously, autoWidth does not properly resize grid columns.

Reproduction:

function App() {
    const [items, setItems] = useState<number[] | undefined>();

    useEffect(() => {
       setTimeout(() => {
           const generatedItems = Array.from({length: 10}, (_, i) => i);
            setItems(generatedItems);
        }, 100);
    }, []);

    return (
        <div>
            <Grid items={items}>
                <GridColumn header="A" autoWidth flexGrow={0} renderer={model => `A long column text ${model.item}`}/>
                <GridColumn header="B" autoWidth flexGrow={0} renderer={model => `B ${model.item}`}/>
                <GridColumn header="C" autoWidth flexGrow={0} renderer={model => `C ${model.item}`}/>
            </Grid>
        </div>
    )
}

Outcome: Bildschirmfoto 2024-01-12 um 11 22 39

Version: 2.4.0-alpha2

Related:

sissbruecker commented 10 months ago

Was also reproducable in the docs grid-content.tsx example using the same alpha version, when removing the workaround for resizing workaround.