You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug Virtualizer doesn't seem to handle when startMargin changes and you get empty space before the rendered list items.
See the video below. It is showing a modified version of the nested example where I am periodically changing the value that is passed to startMargin. This is meant to simulate a page where the value of startMargin depends on a responsive element what might change it's height.
Screencast.from.2024-06-19.17-14-31.webm
To Reproduce
Source code of the modified nested example:
exportconstNested: StoryObj={render: ()=>{constref=useRef<HTMLDivElement>(null);const[paddingTop,setPaddingTop]=useState(0);useEffect(()=>{leti=0;consthandle=window.setInterval(()=>{if(i++%2===0){setPaddingTop(0);}else{setPaddingTop(400);}},5000);return()=>{window.clearInterval(handle);};},[]);constouterPadding=40;constinnerPadding=60;return(<divref={ref}style={{width: "100%",height: "100vh",overflowY: "auto",// opt out browser's scroll anchoring on header/footer because it will conflict to scroll anchoring of virtualizeroverflowAnchor: "none",}}><divstyle={{backgroundColor: "burlywood",padding: outerPadding,
paddingTop,}}><divstyle={{backgroundColor: "steelblue",padding: innerPadding}}><VirtualizerscrollRef={ref}startMargin={outerPadding+innerPadding+paddingTop}>{createRows(1000)}</Virtualizer></div></div></div>);},};
In reality I am using a resize observer to detect when the size of a div that is rendered before the Virtualizer changes and use its height for startMargin. The initial value is 0 and then it changes to something positive.
Expected behavior
There should not be empty space before the rendered list items.
Platform:
OS: Linux
Browser: Firefox and Chromium
Version of this package: latest main (currently a9d55e2)
Version of framework: react
Additional context
It is possible to fill in the empty space by increasing the overscan but there is still flashing while the list is scrolled.
The text was updated successfully, but these errors were encountered:
Describe the bug
Virtualizer
doesn't seem to handle whenstartMargin
changes and you get empty space before the rendered list items.See the video below. It is showing a modified version of the nested example where I am periodically changing the value that is passed to
startMargin
. This is meant to simulate a page where the value ofstartMargin
depends on a responsive element what might change it's height.Screencast.from.2024-06-19.17-14-31.webm
To Reproduce
Source code of the modified nested example:
In reality I am using a resize observer to detect when the size of a
div
that is rendered before theVirtualizer
changes and use its height forstartMargin
. The initial value is 0 and then it changes to something positive.Expected behavior
There should not be empty space before the rendered list items.
Platform:
main
(currently a9d55e2)Additional context
It is possible to fill in the empty space by increasing the overscan but there is still flashing while the list is scrolled.
The text was updated successfully, but these errors were encountered: