Skip to content

fix(drag-and-drop): track all droppable-mailbox directive instances independently#12650

Open
cdvv7788 wants to merge 2 commits intonextcloud:mainfrom
cdvv7788:drag-n-drop
Open

fix(drag-and-drop): track all droppable-mailbox directive instances independently#12650
cdvv7788 wants to merge 2 commits intonextcloud:mainfrom
cdvv7788:drag-n-drop

Conversation

@cdvv7788
Copy link

@cdvv7788 cdvv7788 commented Mar 24, 2026

The droppable-mailbox directive used a single shared instance variable that was overwritten each time a mailbox mounted. This meant only the last-rendered folder in the sidebar had working drag-and-drop, while all others silently failed.

Changes:

  • Use an instances array instead of a single variable in the directive
  • Find the correct instance by element reference on update
  • Add unbind/unmounted hook to clean up listeners on unmount
  • Store bound listener references so removeListeners can properly detach them
  • Remove setInitialAttributes() from update() to prevent clearing drag state during Vue re-renders

Fixes #11930

I added some tests. If you run them against the old code you should be able to see the error. I am able to drop it in the new folders after the changes.

image

@welcome
Copy link

welcome bot commented Mar 24, 2026

Thanks for opening your first pull request in this repository! ✌️

…ndependently

Signed-off-by: Cristian <cristianvargasvalencia@gmail.com>
@kesselb
Copy link
Contributor

kesselb commented Mar 25, 2026

Thanks for your pr 👍

Copy link

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

Fixes a drag-and-drop regression where only the last mounted droppable-mailbox directive instance worked, by tracking directive instances per element and cleaning up listeners on unmount.

Changes:

  • Replace the single shared directive instance with an instances collection and look up the correct instance by el.
  • Add unbind/unmounted cleanup to remove event listeners and prevent leaks.
  • Add unit tests covering multiple instances, correct updates, and listener cleanup behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/directives/drag-and-drop/droppable-mailbox/index.js Track multiple directive instances and add unbind/unmounted cleanup.
src/directives/drag-and-drop/droppable-mailbox/droppable-mailbox.js Store bound listener references so removeListeners detaches correctly; avoid resetting drag state on update.
src/tests/unit/directives/droppable-mailbox.spec.js Add tests for multi-instance behavior, correct updates, and listener removal.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kesselb
Copy link
Contributor

kesselb commented Mar 25, 2026

Thanks a lot @cdvv7788 for fixing it.

Could you check the linter and have brief look at copilots suggestions? The update one seems valid. The "brittle" tests is accetable for me.

@cdvv7788
Copy link
Author

I will check them, they are all relatively simple to fix.

Signed-off-by: Cristian <cristianvargasvalencia@gmail.com>
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

Successfully merging this pull request may close these issues.

dropp mail in custom folder not possible

3 participants