Skip to content

Conversation

@tumispro
Copy link
Contributor

@tumispro tumispro commented Oct 7, 2025

This wasn't easy, but I think I got it working pretty robustly 🙂

Functionality:

  • Auto scroll the container (or window if applicable) when dragging items near the edges
    - Prevent default browser scrolling (when auto scrolling is disabled), inspired by @phoebejaffe's solution (Autoscroll #4 (comment))

This is a work in progress as it doesn't (and might never) support horizontal scrolling and it still needs to be tested thoroughly. It works pretty nicely so far for a few implementations I did myself though.

Update: supports both vertical as well as horizontal auto scrolling now. Worked smoothly in all my tests:

  • Vertical list within window
  • Vertical list within container
  • Vertical list within an element within a container (nested)
  • Horizontal list within window
  • Horizontal list within container
  • Horizontal list within an element within a container (nested)

This was referenced Oct 7, 2025
@ValentinH
Copy link
Owner

Thanks a lot for taking the time to work on this. I'll try to carefully review this later this evening.
After quickly having a look, I don't think that when autoScroll is false, we should disable the scrolling of the parent container. This can be done outside of the lib if people have the need but it could create issues for existing users of the library.
One case I have in mind is the whole body shifting to the right due to the scrollbar being removed.

@tumispro
Copy link
Contributor Author

tumispro commented Oct 7, 2025

Ah you are probably correct. I will remove that behaviour entirely tonight or tomorrow if I find some more time. I was considering to enable it when autoscrolling is enabled, so that the dragged item doesn't show above the scrollbar when the scrollable element is a container, but I guess that isn't too much of an issue as showing the scrollbar is more useful/important.

Take your time and thanks for your quick response!

@tumispro
Copy link
Contributor Author

tumispro commented Oct 7, 2025

Removed the disabling of the default browser scroll behaviour

@socket-security
Copy link

socket-security bot commented Oct 7, 2025

No dependency changes detected. Learn more about Socket for GitHub.

👍 No dependency changes detected in pull request

Copy link
Owner

@ValentinH ValentinH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the vertical list story to show the new feature.

@tumispro
Copy link
Contributor Author

tumispro commented Oct 8, 2025

Was testing a bunch of different implementations and the lack of horizontal scroll support stung me, so added that as well. Wasn't too big of a change compared to the vertical auto scroll 🔥

@ValentinH
Copy link
Owner

It looks great! I've updated the other stories.

Can I go ahead and merge this?

@tumispro
Copy link
Contributor Author

tumispro commented Oct 8, 2025

I feel it's functionally complete and it passed all the different implementation tests I did. As it's optional and off by default releasing it should be fine imo. Thanks for your swiftness as always!

@tumispro
Copy link
Contributor Author

tumispro commented Oct 8, 2025

Tested some more and fixed a small bug where it stopped working when an axis was locked (axes check was swapped)

@ValentinH
Copy link
Owner

I'll do a last review and merge this tonight 👍

@ValentinH ValentinH added the enhancement New feature or request label Oct 8, 2025
@ValentinH ValentinH merged commit ce1555c into ValentinH:main Oct 8, 2025
2 checks passed
@ValentinH
Copy link
Owner

Published as react-easy-sort@1.8.0 🎉

Thanks again @tumispro !!

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

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants