Skip to content

Support steps option for dragging #182

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

Merged
merged 1 commit into from
Nov 20, 2022

Conversation

swanson
Copy link
Contributor

@swanson swanson commented Jan 8, 2022

I've been trying to get a system test working with https://sortablejs.github.io/Sortable/

I had to do two things:

  • Change the sortable forceFallback config to true: this is an application level change to not use HTML native drag and drop and use a different event fallback
  • Add steps to the mouse.move calls

This PR adds an option to pass steps to use when dragging in case you need to more closely simulate dragging the mouse across the browser (vs the current "teleport" behavior)

@swanson swanson changed the title Support option for dragging Support steps option for dragging Jan 8, 2022
@swanson
Copy link
Contributor Author

swanson commented Jan 11, 2022

@route would you be able to review?

@route
Copy link
Member

route commented Jan 11, 2022

Yea sorry busy week at work, going to to do it

@swanson
Copy link
Contributor Author

swanson commented Feb 14, 2022

@route hi, just wanted to check in on this and see if there was anything I could help with getting this merged. Been running with this patch on my project for a few weeks now without any problems.

@mrtnin
Copy link

mrtnin commented Feb 14, 2022

@swanson Can you share an example of usage too? I have tried your patch without any luck.

@swanson
Copy link
Contributor Author

swanson commented Feb 14, 2022

@mrtnin

test "Can drag and drop content blocks from toolbar onto page" do
  visit "/pages/new"

  text_block = find("#toolbar div", text: "Text Block")
  sidebar = find("#sidebar)

  text_block.drag_to(sidebar, steps: 10)
  page.driver.wait_for_network_idle

  within "#sidebar" do
    assert_text "Enter text content"
  end
end

I am using this in combination with the Sortable.js library and I set the option for forceFallback to true when running my app in the Rails test environment (via a variable in my Stimulus controller that initializes Sortable). This option uses a fallback instead of the HTML5 drag and drop APIs which don't seem to work.

Without the steps: 10 the dragging is more like a "teleport" where the block just goes straight to the sidebar.

@route route merged commit 7ace9f6 into rubycdp:master Nov 20, 2022
richardboehme added a commit to richardboehme/lexorank-demo that referenced this pull request Apr 14, 2023
Huge thanks to the user reporting and providing a fix for this specific
issue in rubycdp/cuprite#182!
richardboehme added a commit to richardboehme/lexorank-demo that referenced this pull request Apr 14, 2023
Huge thanks to the user reporting and providing a fix for this specific
issue in rubycdp/cuprite#182!
@trobrock trobrock mentioned this pull request Feb 9, 2024
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

Successfully merging this pull request may close these issues.

3 participants