[stable5.7] fix(drag-and-drop): track all droppable-mailbox directive instances independently#12669
[stable5.7] fix(drag-and-drop): track all droppable-mailbox directive instances independently#12669backportbot[bot] wants to merge 3 commits intostable5.7from
Conversation
590504d to
fc0390d
Compare
|
Backport does not apply clean because DroppableMailboxDirective looks different on stable5.7 due to #12596. Partial backport should be fine, or would you prefer to drop the vue3 definitions @ChristophWurst? |
There was a problem hiding this comment.
Pull request overview
Backport to stable5.7 that fixes sidebar drag-and-drop by tracking each v-droppable-mailbox directive instance independently and cleaning up listeners on unmount.
Changes:
- Replace the single shared directive instance with per-element instances stored in a
WeakMap - Ensure listeners are removed on unbind/unmount and that
removeListenersuses the same bound function references - Add unit tests covering multiple instances, updates, and cleanup behavior
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/tests/unit/directives/droppable-mailbox.spec.js | Adds unit tests validating independent instances, updates, and listener cleanup |
| src/directives/drag-and-drop/droppable-mailbox/index.js | Refactors directive to track instances per element and adds unbind/unmounted cleanup |
| src/directives/drag-and-drop/droppable-mailbox/droppable-mailbox.js | Stores bound handler references so event listeners can be removed correctly |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }, | ||
| componentUpdated(el, binding) { | ||
| function onBind(el, binding) { | ||
| const instance = new DroppableMailbox(el, binding.value) |
There was a problem hiding this comment.
DroppableMailbox is constructed here with only (el, binding.value), but the class constructor signature is constructor(el, componentInstance, options). This means options becomes undefined and options.mainStore will throw at runtime. Pass binding.value as the third argument (and optionally provide the Vue component instance as the second arg for Vue 2/3), or update the DroppableMailbox constructor to match the new call site.
| const instance = new DroppableMailbox(el, binding.value) | |
| const instance = new DroppableMailbox(el, undefined, binding.value) |
…ndependently Signed-off-by: Cristian <[email protected]>
Signed-off-by: Cristian <[email protected]>
Signed-off-by: Cristian <[email protected]>
fc0390d to
fc4d4e5
Compare
How to test:
Main: It's not possible to drop on the latest mailbox/folder on the list
Here: It works
Backport of #12650
Warning, This backport's changes differ from the original and might be incomplete⚠️
Todo
Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.