bvaughn / react-virtualized

React components for efficiently rendering large lists and tabular data
http://bvaughn.github.io/react-virtualized/
MIT License
26.31k stars 3.05k forks source link

Scroll restoration doesn't work with AutoSizer #1693

Closed meotimdihia closed 1 month ago

meotimdihia commented 3 years ago

Bug Report

Scroll restoration doesn't work with AutoSizer. This is my code: **rowCount is changed because it's an infinite scroll list.

        <WindowScroller>
          {({ height, isScrolling, onChildScroll, scrollTop }) => (
            <AutoSizer disableHeight>
              {({ width }) => (
                <List
                  autoHeight
                  rowCount={comics.length}
                  height={height}
                  width={width}
                  rowHeight={cache.rowHeight}
                  deferredMeasurementCache={cache}
                  isScrolling={isScrolling}
                  onScroll={onChildScroll}
                  scrollTop={scrollTop}
                  scrollToIndex={50}
                  rowRenderer={({ index, isScrolling, key, parent, style }) => (
                    <CellMeasurer
                      cache={cache}
                      columnIndex={0}
                      key={key}
                      parent={parent}
                      rowIndex={index}
                    >
                    ...

Which versions of React and react-virtualized, and which browser / OS are affected by this issue? Did this work in previous versions of react-virtualized?

Browser Chrome
OS Window
React 17.0.5
React DOM 17.0.5
react-virtualized 9.22.3
amitShimon1983 commented 2 years ago

i have the same problem

hyunmindev commented 2 years ago

I had the same bug. But in my case, Adding registerChild prop was helpful.

<WindowScroller>
  {({ height, isScrolling, onChildScroll, scrollTop, registerChild }) => (
    <AutoSizer disableHeight>
      {({ width }) => (
        <div ref={registerChild}>
          <List
            ...

https://github.com/bvaughn/react-virtualized/blob/master/docs/WindowScroller.md#render-props