cuprite icon indicating copy to clipboard operation
cuprite copied to clipboard

Support `steps` option for dragging

Open swanson opened this issue 3 years ago • 5 comments

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 avatar Jan 08 '22 04:01 swanson

@route would you be able to review?

swanson avatar Jan 11 '22 17:01 swanson

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

route avatar Jan 11 '22 18:01 route

@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.

swanson avatar Feb 14 '22 14:02 swanson

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

mrtnin avatar Feb 14 '22 14:02 mrtnin

@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.

swanson avatar Feb 14 '22 14:02 swanson