Skip to content

[stable5.7] fix(drag-and-drop): track all droppable-mailbox directive instances independently#12669

Open
backportbot[bot] wants to merge 3 commits intostable5.7from
backport/12650/stable5.7
Open

[stable5.7] fix(drag-and-drop): track all droppable-mailbox directive instances independently#12669
backportbot[bot] wants to merge 3 commits intostable5.7from
backport/12650/stable5.7

Conversation

@backportbot
Copy link
Copy Markdown

@backportbot backportbot bot commented Mar 27, 2026

How to test:

  • Click on a message and hold
  • Drag the message to a folder to move it

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

  • Review and resolve any conflicts
  • Review and verify the backported changes
  • Amend HEAD commit to remove the line stating to skip CI

Learn more about backports at https://docs.nextcloud.com/server/stable/go.php?to=developer-backports.

@kesselb
Copy link
Copy Markdown
Contributor

kesselb commented Mar 31, 2026

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?

@kesselb kesselb self-assigned this Mar 31, 2026
@kesselb kesselb marked this pull request as ready for review March 31, 2026 11:23
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 removeListeners uses 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)
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const instance = new DroppableMailbox(el, binding.value)
const instance = new DroppableMailbox(el, undefined, binding.value)

Copilot uses AI. Check for mistakes.
@kesselb kesselb force-pushed the backport/12650/stable5.7 branch from fc0390d to fc4d4e5 Compare March 31, 2026 11:28
@kesselb kesselb added the bug label Mar 31, 2026
@kesselb kesselb requested review from GVodyanov March 31, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants