Subscribe on changes!

Emit sometimes does not emit custom events or overriden native events (dragend)

avatar
Oct 9th 2023

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#__DEV__eNrFW3tz2zYS/yqo26vkiUQ7r39UO67rOD3fJXYn8XTuxs5kaAmSmFCkjqQke1x/99vFcwGCpNxHmpmMJWCxWOwufrtYQPc7x8tltF7xndHOQTkukmXFSl6tlq+us2SxzIuK3bOCTwcs47fVZTL+wh7YtMgXrAeDeobodRHPZrxQXdGe+o6cez8Yqvf5xlDAZ6/3dZEvz7JJMo6rnHIird6Ie7Yq+Qf4dJKnKR9XSZ4Z8aK9Wl/0ucTB19k4z8oKljVOlgnPqpId4hr7V/esTGZZks0uigkvRsB/HacrPmJP2QNoIF7Ax940Kcqqhw2N5M8Ieclhtkk7/XNCX82TooP8BZUmXxXVvEOcly/JiDQW4n/ctZq4v84YKx1dCQMCr0G966JIoCdOwSr8NtB/zjdNXcj1Ys2Lhq4PVVxUDX2n2UT0JOVbWMCvuLLyg+w+zeKblGP3A1iyZvZ+YHkjYn3BNked/ZvfocWIFnui8yaNsy/gsOWI7XcIMWJVseIoyi5xtXmcTVJPLLWok1VZgb8esri8y8asz9cg08CKt8sOX0kDIas85VGaz/q9f4wVU8WGjQWf3oD1buLxl1mRrzIQ5ttnz579ACPTHBzi2/39KfzroWSwhinrB9VcF2FXCsBYvImTykBBXzJibG+PRVGEnx9g4dut+zyukjX/4+vOBJ/2dd/Ek/jly6+w7oM9iaGAnvCl4otlGlccvjF2AP4jR62H07w4vN7pm4kGLMENswt/iF9e70j60Rd+B+SC5HqHjQwFNJrPhtiOp92WmWkaCoaWseqfqI0PHWFEMJQZ3xgeYQRwmA5z2PhBrogIklToDUccqAAiv6HOFvmEp3RJEd2nkYA6PZ/c7UMwv5plWOSbodjiQ6lMOtaOGnkqAW3lm5CWgdQyD+oZKNZJmQAkaHbsm0MMM5owSnk2q+Z08nKI2DwUSymHEDiE6FwCC7JpRB3CxV/5AtQ+LBFYG4zlwL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//4Iv218/wrRncb2WindRHVyiqZHF3OH12DQWLy3YOK1l7IhlPWIaxN9ojncTixFP3v5wtG5RyEI6lLL8CBmf6tLs+KbU691QN/KiNOSoV7uiOpoS2/gCRpc4VaukGTuKztRcxQCT2IJhjJDa7o2c3j2CZgCKT9dH0QiOkkS2KHgEnXhnNV1cfC0Txw6efIkrBSBf55GEeY8O2LhHWpV7QJsb4lWb0x8J6QoQviEiipwGBIDT8QMWJkgxyRbJnfLFY8ojKpNoK5QwGK9tz2lLtKW9ry8wHaTa3fnREHEDNg1OMitB4cPjlvUSrB0ocWjJzyV4yXleXzel1/M0uG3O85Z1L10t09r6yJ4L1nhOYt8eNtxhRfBAxONqP6DYWyOEjhVwEqIGqHJp2SQMN1jMo9DBswqGn/Op5pto7jHRdm6lfjgFmLVO1MhmXdUs8cA91UPUYWva0LzYK4/XFxodZ5O8b9ybW37oyhZl76MJ030aGK4+EPsvUFczaNFkvXtXhqoxvi2D09iwyPVe4HwmVJfVHuJy6OV+GgVtkd91dtw9Wd+z9laCG7o9n6d2r3gBhr7K9Zgd+h5RANpvZLWQOiGhpbly5/QNnarn9E29ouf0mowbvk5LTGbcH18x0kedcF7Mf8hlsXI/OazAQAEfPFuFqBa/BW9BB+UO0CrQFHDxQmp6tB78xkzFXw1CFeZ+E3EM/gAwtOgpnIpZIPlnHu5DtsDvwPE5xvyWXCE34RUhkpcnOosCm5N8BIBqXTmB+0HLMU/eOXlgJ2ZQA2BRIRAixTpCjrwCtXRmGhsTqHlSFcnVnXETg//B9Nkttk=

Steps to reproduce

  1. Drag the item in 'Always last' section to some other item and drop it. (the handle looks like '...255', the drop area shows 'listening' when dragging and 'visible' for where the drop will end up)
  2. In console you can see logs for what happened
  3. See what is expected in expected section below

If you drag for example the first item to the third item it works as expected, custom event is called (as well as native but in my codebase the custom event is called 'dragend' so it overrides it)

What is expected?

Custom dragend event should have been called and there should be a log in a console for it.

What is actually happening?

Only native dragend event has been called and is logged in the console

System Info

System (WSL2 on Windows 11):
    OS: Linux 5.10 Ubuntu 20.04.5 LTS (Focal Fossa)
    CPU: (16) x64 AMD Ryzen 7 6800HS with Radeon Graphics
    Memory: 11.14 GB / 15.27 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.19.0 - ~/.nvm/versions/node/v16.19.0/bin/node
    Yarn: 1.22.17 - ~/workspace/digisign/app/node_modules/.bin/yarn
    npm: 9.7.1 - ~/.nvm/versions/node/v16.19.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.119
  npmPackages:
    vue: ^3.3.4 => 3.3.4

Any additional comments?

Last working version of Vue was 3.3.2. Could not try it on 3.3.3 cause of a bug fixed in 3.3.4.

When trying to change version in Vue SFC Playground it happens in any of them. Yet it works on version 3.3.2 and lower in the codebase I work on.

Playground with the bugged behavior, not just console logs In the playground with bugged behavior in the link above you can see how it gets stuck in drag when the event is not called.

Background/context: We have a collection that can be sorted using drag 'n' drop (or input [not included]) with some custom behavior the 'Always last' section where the items are set to constant 255 and are separated from the other items ). The dragend ervent stopped working on latest version of Vue when dragging from the 'Always last' section back to the normal section. It worked on version 3.2.45 and when tested also on 3.3.2

avatar
Oct 10th 2023

Hello @ondrej-tesar-digital The issue is that you're using the index as key for the Row components and you're mutating the list of recipients, which causes the element on which the dragStart fired to be unmounted, thus no dragEnd event will be emitted

If you try a unique key for each recipient, it should work as expect For example, I saw that you duplicate the recipient with hidden: true so a :key="`${recipient.name}-${recipient.hidden}`" should work (you can implement better ways to uniquely identify each entry)

avatar
Oct 12th 2023

Oh wow. Thanks! @OBe95

And here I though for the first time the problem is not between the computer screen and the chair, but here I am 😄