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

useWindowAsScrollContainer should not crawl to root node #577

Open
knarkunas opened this issue Jul 25, 2019 · 3 comments
Open

useWindowAsScrollContainer should not crawl to root node #577

knarkunas opened this issue Jul 25, 2019 · 3 comments

Comments

@knarkunas
Copy link

knarkunas commented Jul 25, 2019

There is an issue with grid and useWindowAsScrollContainer. It should not be crawling up to first overflow: scroll|auto DOM element. As seen in getScrollingParent(this.container). Result is something like this using grid layout:
image_sort_bug_known
image_sort_bug_example

Or we could get a prop of some sort for grid layout when scroll is not used at all?
Like isScrollable and then this code:

this.scrollContainer = useWindowAsScrollContainer
          ? this.document.scrollingElement || this.document.documentElement
          : getScrollingParent(this.container) || this.container;

becomes

if (isScrollable) {
     this.scrollContainer = useWindowAsScrollContainer
               ? this.document.scrollingElement || this.document.documentElement
               : getScrollingParent(this.container) || this.container;
} else {
      this.scrollContainer = this.container;
}

Currently animateNodes inside SortableContainer.js does transformation and calculation ends up this.containerBoundingRect having to be root element (most websites has overflow scroll somewhere, right?).
edgeOffset.left + translate.x > this.containerBoundingRect.width - offset.width

Current workaround, if you want to have non scrollable, simple grid box layout and draggable list is to add <div style={{ overflow: 'auto' }}> around your SortableContainer. And do not forget to set useWindowAsScrollContainer to false.

Example to reproduce:
https://codesandbox.io/s/serene-dawn-rwpj0

Commit that might be affecting this issue:
#507

@knarkunas
Copy link
Author

Possible other issues related to this one:
#551
#523
#520

@zalevsk1y
Copy link

It began with version 1.8.0. Before this, in version 1.7.1, the parent container was simply taken for the calculation.

const containerBoundingRect = this.container.getBoundingClientRect();

@Mathieu-DA
Copy link

Thanks knarkunas! Your workaround saved my day. It's the 'overflow: auto' that did the trick.
I didn't have to set useWindowAsScrollContainer to false.

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

3 participants