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

Auto-scroll moves up constantly during horizontal dragging! #1040

Closed
matttk opened this issue Jan 3, 2019 · 14 comments
Closed

Auto-scroll moves up constantly during horizontal dragging! #1040

matttk opened this issue Jan 3, 2019 · 14 comments

Comments

@matttk
Copy link

matttk commented Jan 3, 2019

Bug or feature request?

Bug

Expected behavior

Scrolling horizontally should never activate vertical autoscroll, unless you actually try to scroll vertically.

Actual behavior

Scrolling horizontally instantly activates vertical autoscroll up (until the top of the page is reached) under certain circumstances.

Steps to reproduce

I actually can't figure out how to reproduce it normally but I did manage to get the exact same behaviour in this codesandbox.io, using the example as a basis and building in my own code.

I still couldn't reproduce it until I noticed that if you shrink the vertical width of the screen, it eventually starts happening. This goes to my theory that there is something going on in the autoscroll calculations, involving the height of various divs...

Make the window as small as in the below picture and then drag a card left or right. The screen will start moving up slowly.

image

What version of React are you using?

16.3.1

What version of react-beautiful-dnd are you running?

10.0.3

What browser are you using?

Chrome, latest version for Windows 10.

Demo

My demo is based on your boilerplate and another one that included SCSS support.

Again, make sure to shrink the screen enough (like in the above picture) and then start dragging.

However, in my actual code, I get the problem always, even with the browser window maximised. It's only that I couldn't figure out how to reproduce it in the code sandbox.

I can imagine that I am missing something necessary in the CSS, which is tripping up the autoscroll calculations but I can't find the problem... I'm hoping that this too small screen version I did find in the code sandbox is the same problem or at least related to mine.

@treshugart
Copy link

Hey @matttk, just want to let you know we'll look into this as soon as we can. Alex, the maintainer, will be back soon. For more info, see #1010.

@alexreardon
Copy link
Collaborator

Okay, so this has to do with how auto scrolling works. If you drag something near the edge of a browser, we will scroll the browser if it can be scrolled. This is true even when the movement is on any plane (vertical or horizontal).

In your posted example, i am not sure why the auto scroll only goes up and not also down as you move the item lower. This is worth looking into

@matttk
Copy link
Author

matttk commented Jan 23, 2019

If you drag something near the edge of a browser, we will scroll the browser if it can be scrolled. This is true even when the movement is on any plane (vertical or horizontal).

But the scrolling starts the instant I pick up the item, not when I move it to the edge of the screen. Also, why would it just start auto-scrolling in any available direction (always up), even when you are not on the top edge?

@alexreardon
Copy link
Collaborator

I'll take a deeper look @matttk

@alexreardon
Copy link
Collaborator

This one is confusing. When I moved it onto my local everything worked as expected...

But there is an issue on the codesandbox one 🤔

@alexreardon
Copy link
Collaborator

Something strange going on. If I add this style it seems to work fine:

html, body {
    width: 100%;
    height: 100%;
}

@alexreardon
Copy link
Collaborator

This one is really hard to get right given there are so many ways a document can be setup 😲

@matttk
Copy link
Author

matttk commented Jan 24, 2019

Something strange going on. If I add this style it seems to work fine:

html, body {
    width: 100%;
    height: 100%;
}

I really thought I tried something like this but maybe I only applied it to the body or html... at any rate, this gets rid of the problem, even if it isn't really the solution. Thanks! 👍

@alexreardon
Copy link
Collaborator

I am working on a fix @matttk that will avoid you needing to add those styles

@alexreardon
Copy link
Collaborator

I went a bit further, it actually has to do with the body / document behaviour differences between doctypes.

By adding the HTML5 doctype to your file everything should work fine

https://codesandbox.io/s/nk2k52xr3p

<!DOCTYPE html>

It could be worth calling this out in the docs

@alexreardon
Copy link
Collaborator

your custom index.html in your codesandbox example did not have a doctype

@alexreardon
Copy link
Collaborator

I have added a new doc section encouraging people to use the html5 doctype

@alexreardon
Copy link
Collaborator

This issue has popped it's head up a few times in unexpected ways. I have added a dev only check to warn people if they are not using a html5 doctype

@ds-martinso
Copy link

Hi,
I seem to still have this issue. Could someone help me understand why my table scrolls up when I want to drag horizontally? (First scroll the table a bit down, and then try to drag a column horizontally. You will see that the table autoscrolls up, but I don't want it to)
Please see this modified sandbox https://codesandbox.io/s/gargroh-v7-drag-column-beautiful-react-dnd-forked-p0rm8?file=/src/index.css
Thanks!

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

No branches or pull requests

4 participants