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

Drop stopped working after the second drag and drop #120

Open
ghost opened this issue Oct 17, 2022 · 3 comments
Open

Drop stopped working after the second drag and drop #120

ghost opened this issue Oct 17, 2022 · 3 comments

Comments

@ghost
Copy link

ghost commented Oct 17, 2022

I want to drag and drop three elements, but after the second drag and drop, it stopped working. The following code console log true, true, false. Any idea why?

   "@4tw/cypress-drag-drop": "^2.2.1",
    "cypress": "^9.4.0",
  cy.get('[data-type="app.RectangularModel"]')
    .drag('.joint-paper-scroller')
    .then((success) => {
      console.log(success)
    })

  cy.get('.simplebar-wrapper [data-type="app.SchemaNoteModel"]')
    .drag('.joint-paper-scroller')
    .then((success) => {
      console.log(success)
    })

  cy.get('.simplebar-wrapper [data-type="app.SchemaNoteModel"]')
    .drag('.joint-paper-scroller')
    .then((success) => {
      console.log(success)
    })
@Yogendiran-Subramanian
Copy link

Yogendiran-Subramanian commented Dec 27, 2022

I'm facing the same issue but after the first try itself.
Only on the first try, it get passed, on the second try, it's getting failed.

While inspecting I found the below part is repeating again and again
wrap<locator>
triggerdragover, Object{5}
triggermousemove, Object{4}
triggerpointermove, Object{4}
wait10
For me the above thing repeated for 6 times before failing

@maxgruebneraeroqual
Copy link

maxgruebneraeroqual commented Feb 8, 2023

I'm having the same issue as Yogendiran Subramanian

I had a poke at the source (from index.js), it looks like dragstart recursively calls itself, and I can't see where it would break out by setting dropped to true, although my understanding of JS and cypress is spotty.

  dragover(clientPosition = {}) {
    if (!this.counter || (!this.dropped && this.hasTriesLeft)) {
      this.counter += 1
      return this.target
        .trigger('dragover', {
          dataTransfer,
          eventConstructor: 'DragEvent',
          ...this.options.target,
        })
        .trigger('mousemove', {
          ...this.options.target,
          ...clientPosition,
          eventConstructor: 'MouseEvent',
        })
        .trigger('pointermove', {
          ...this.options.target,
          ...clientPosition,
          eventConstructor: 'PointerEvent',
        })
        .wait(this.DELAY_INTERVAL_MS)
        .then(() => this.dragover(clientPosition))  <---- recursive?
    }
    if (!this.dropped) {
      console.error(`Exceeded maximum tries of: ${this.MAX_TRIES}, aborting`)
      return false
    } else {
      return true
    }
  }

I sorted it by removing the call to dragover inside dragover and putting that in a custom command. Seems happy now 🤷‍♀️

@cristinaandreeacaescu
Copy link

Any updates ? we are having the same issue and it is a huge blocker for us.

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

3 participants