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

Autoscroll causes draggable items and click events to become offset from mouse positioning on Safari desktop #1333

Open
jhea0008 opened this issue Jan 28, 2024 · 7 comments

Comments

@jhea0008
Copy link

safari-dndkit-bug-480.mov

After using the drag auto scroll on elements in safari, the sortable list and draggable element behind the dragOverlay gets out of position, and once dropped, mouse events register against the wrong draggable element.

Bug present on macOS 14.2.1 and 14.3 on both Intel and M1. Safari versions 17.3 and 17.2.1. Not sure about older versions as I haven't tested them.

Bug is not present in other browsers such as chrome, firefox or safari iOS

It can be seen as per the video on Sortable vertical basic setup in storybook, and I have also tested it on other drag overlay scenarios without sortable, where it is still present.

@nikischin
Copy link

I am having the same issue and it's quite annoying as I have no idea how to fix it... though I really don't understand as it was working in the morning and just randomly stopped working in the afternoon after I restarted my Mac...

@notmedia
Copy link

notmedia commented Apr 6, 2024

any updates on this?

@JulienRioux
Copy link

I had the same issue using a custom dnd context. Basically, the fix form me was to round scrolling distance before applying it. The issue is that Safari is less precise with large decimal numbers, leading to cumulative inaccuracies that grow into a significant offset during automatic scrolling.

@Zwen1111
Copy link

I had the same issue using a custom dnd context. Basically, the fix form me was to round scrolling distance before applying it. The issue is that Safari is less precise with large decimal numbers, leading to cumulative inaccuracies that grow into a significant offset during automatic scrolling.

Could you explain how you achieved this? I don't want to create a custom dnd context just for this issue.

@JulienRioux
Copy link

I don't know well the package but it seems like making the following change could work. Our issue was around the autoScroller implementation:

const scrollLeft = Math.round(scrollSpeed.current.x * scrollDirection.current.x);
const scrollTop = Math.round(scrollSpeed.current.y * scrollDirection.current.y);

const scrollLeft = scrollSpeed.current.x * scrollDirection.current.x;
const scrollTop = scrollSpeed.current.y * scrollDirection.current.y;

@JulienRioux
Copy link

Basically, the issue is that you need to round the multiplication of the scrolling speed and the scrolling distance. You can also check if the user is on Safari and other browser that have the same issue.

@robinweser
Copy link

@JulienRioux Would it make sense to create a PR with that Math.round applied? I'm currently running into the same issue and would rather not want to provide my own auto scroller.

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

6 participants