Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Props ScrollElement of WindowScroller load every items if parent is InfiniteLoader #1830

Open
albanlorillard opened this issue Jan 15, 2024 · 2 comments

Comments

@albanlorillard
Copy link

Hi !

Bug Report

What is the current behavior?

I try to attach the scroll of a WindowScroller with the scrollElement props on a parent HTML section. I use "useRef" Hook for this.
My WindowScroll has an InfiniteLoader component as a parent.

If I directly link the ref on scroll Element like this ;

<WindowScroller
            scrollElement={myElementRef.current}
          >

There is no element loaded.

If I add a checkbox to change the state between default case (scrollElement = window) and scrollElement myElementRef.current, every elements are loaded in the DOM. There is no virtualization.

Code Sandbox

What is the expected behavior?

I suppose to make work the InfiniteLoader component with scrolling on a part of my page. I would like to have the scroll attach (like on the demonstration here : https://bvaughn.github.io/react-virtualized/#/components/WindowScroller) with an infiniteLoader and the virtualization work.

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 Firefox & Chome latest version
OS Mac OS - Sanoma 14.2
React 18.2
React DOM 18.2
react-virtualized 9.22.5
@guilanxiao
Copy link

met the same issue. Do you have solutions for this case ?

@albanlorillard
Copy link
Author

albanlorillard commented Mar 7, 2024

I finally do the same that the example.

I create a container with a fixed height in the CSS and with the same properties in the example:

display: 'flex',
     position: 'relative',
     overflow: 'auto',
     height: '200rem',

I got his ref (scrollContainer) and I put it in the windowScroller
then I introduce a state "withScrollElement" to switch the scrollElement prop from window to my scrollContainer ref.

  <WindowScroller
                         scrollElement={withScrollElement && scrollContainer?.current ? scrollContainer.current : window}
           >

I switch withScrollElement to true when my component finish to render.

It's a little dirty but work fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants