react-spectrum
react-spectrum copied to clipboard
ListView animations don't work properly with variable height rows
Provide a general summary of the issue here
When creating a ListView with variable height rows, the animations that occur when adding a new row are pretty janky. The animation transaction occurs prior to the measurement or the row, so the animation assumes that the row is the estimated height and animates the list accordingly. Only once the animation transaction has finished does the list update with the correct height.
๐ค Expected Behavior?
I'd expect the animations to work seamlessly with variable sized rows.
๐ฏ Current Behavior
A video demonstrating the janky animation:
https://github.com/adobe/react-spectrum/assets/1236841/e653e2ef-dd3c-43cd-bd0d-5857a76d0fbf
And the associated code: https://stackblitz.com/edit/stackblitz-starters-vanwph?file=SpectrumExample.tsx
๐ Possible Solution
The animation transaction in Virtualizer occurs when the collection updates, but before the dom measurement of the newly inserted row has occurred. We likely need a way to defer that animation transaction until measurements have occurred, which doesn't seem possible currently.
๐ฆ Context
We are trying to build a similar primitive to Spectrum's ListView, based upon Virtualizer from react-stately but we ran into this problem when supporting dynamic height rows. I was able to replicate the issue in Spectrum's ListView to confirm it wasn't just our implementation that was at fault.
๐ฅ๏ธ Steps to Reproduce
https://stackblitz.com/edit/stackblitz-starters-vanwph?file=SpectrumExample.tsx
Which is based upon an example from the docs.
Version
3.34.1
What browsers are you seeing the problem on?
Chrome, Safari
If other, please specify.
No response
What operating system are you using?
Ventura 13.3
๐งข Your Company/Team
Frame.io
๐ท Tracking Issue
No response
Thanks, I'll link this in the other two Virtualizer tickets so we can track this when we pick that work back up