petyosi / react-virtuoso

The most powerful virtual list component for React
https://virtuoso.dev
MIT License
5.16k stars 299 forks source link

[BUG] Width of fit content does not work on virtualized list #1027

Closed IsaacAbrahamson closed 7 months ago

IsaacAbrahamson commented 7 months ago

Describe the bug Setting width: 'fit-content' causes the virtualized list to have no width at all. I want to have a list where the width is based on the width of the largest visible item which is what fit-content should do. I'm not really sure this is that valid of a use case, but I don't think there should be no width at all when this is used.

Reproduction

CodeSandbox

To Reproduce Steps to reproduce the behavior:

  1. Go to sandbox
  2. Select both checkboxes
  3. Press open list button
  4. See that list has no width
  5. Uncheck "Virtualized" checkbox to see how I expect it to look

Expected behavior

I expected the width to be the largest item that is currently visible. In my linked example I have this set to a fixed width for every item.

Screenshots

Screenshots Screenshot 2024-01-22 at 4 07 28 PM Screenshot 2024-01-22 at 4 07 55 PM

Desktop (please complete the following information):

petyosi commented 7 months ago

That's not supported due to the styling of the virtualized list - to be more precise, the position: relative.