Skip to content

[#71325, #71327] Drag and drop fixes#21842

Merged
myabc merged 5 commits intorelease/17.1from
bug/71325-drag-and-drop-turbo-interop
Feb 3, 2026
Merged

[#71325, #71327] Drag and drop fixes#21842
myabc merged 5 commits intorelease/17.1from
bug/71325-drag-and-drop-turbo-interop

Conversation

@myabc
Copy link
Copy Markdown
Contributor

@myabc myabc commented Feb 2, 2026

Ticket

https://community.openproject.org/wp/71325
https://community.openproject.org/wp/71327

What are you trying to accomplish?

WP 71325

Improves GenericDragAndDropController's interop with Turbo's partial page updates: although not reproducible in current production code, list items are sometimes no longer draggable after a partial page update.

WP 71327

Fixes an issue where the drag handle doesn't actually drag if clicked in the wrong place.
Removes draggable="true" which enables HTMl5 Drag and Drop API, conflicting with our Dragula-based implementaiton.
Updates drag handle detection to use closest() for more reliable matching.

Screenshots

There should be no visual changes.

What approach did you choose and why?

This patch attempts to handle page changes "idiomatically" via Stimulus lifecycle callbacks rather than a hand-rolled MutationObserver-based implementation.

Merge checklist

  • Added/updated tests
  • Added/updated documentation in Lookbook (patterns, previews, etc)
  • Tested major browsers (Chrome, Firefox, Edge, ...)

myabc added 4 commits February 2, 2026 17:33
Improves `GenericDragAndDropController`'s interop with Turbo's partial
page updates: although not reproducible in current production code, list
items are sometimes no longer draggable after a partial page update.

This patch attempts to handle page changes "idiomatically" via Stimulus
lifecycle callbacks rather than a hand-rolled `MutationObserver`-based
implementation.

https://community.openproject.org/work_packages/71325
Although the result should be the same in evergreen browsers, `:scope`
pseudo-selector has been around longer and as such, is better supported
than the CSS nesting selector (`&`).

See:
- https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:scope
- https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/Nesting_selector
Allows overriding default drag handle selector via a Stimulus value.
Uses `.DragHandle` class by default (rather than the octicon class),
maintaining compatibility with PVC `DragHandle` component.

Also sets `aria-pressed` on drag handle while dragging.
`draggable="true"` enables HTML5 Drag and Drop, which conflicts with the
Dragula-based implementation used by `GenericDragAndDropController`.

https://community.openproject.org/wp/71327
@myabc myabc changed the title [#71325] Fix drag and drop controller Turbo interop [#71325, #71327] Drag and drop fixes Feb 2, 2026
@myabc myabc changed the base branch from dev to release/17.1 February 2, 2026 20:34
@myabc myabc force-pushed the bug/71325-drag-and-drop-turbo-interop branch from 90da221 to b947e0d Compare February 2, 2026 20:35
@myabc myabc marked this pull request as ready for review February 2, 2026 20:37
Copilot AI review requested due to automatic review settings February 2, 2026 20:37
Copy link
Copy Markdown
Contributor

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

This PR fixes two drag-and-drop issues: improving GenericDragAndDropController's handling of partial page updates through Turbo by replacing manual MutationObserver logic with Stimulus lifecycle callbacks, and fixing drag handle functionality by improving the selector matching logic.

Changes:

  • Refactored GenericDragAndDropController to use Stimulus targets and lifecycle callbacks instead of MutationObserver
  • Updated drag handle detection to use closest() for more reliable matching
  • Replaced data-is-drag-and-drop-target attribute with generic_drag_and_drop_target: "container" across components
  • Changed CSS selector syntax from & to :scope in container accessor attributes
  • Removed draggable: true parameter from DragHandle component instantiations

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/src/stimulus/controllers/dynamic/generic-drag-and-drop.controller.ts Refactored to use Stimulus targets/lifecycle callbacks, improved drag handle detection, removed MutationObserver implementation
frontend/src/stimulus/controllers/dynamic/meetings/drag-and-drop.controller.ts Simplified cancel logic to use new cancel() method
modules/meeting/app/components/meeting_sections/show_component.rb Updated to use new target attribute syntax
modules/meeting/app/components/meeting_sections/header_component.rb Removed unused drag-and-drop target config method
modules/meeting/app/components/meeting_agenda_items/list_component.rb Updated to use new target attribute syntax
app/components/work_package_types/export_template_list_component.rb Updated target attribute and changed selector from & to :scope
app/components/settings/project_phase_definitions/index_component.rb Updated target attribute and changed selector from & to :scope
app/components/settings/project_custom_field_sections/show_component.rb Updated to use new target attribute syntax
app/components/settings/project_custom_field_sections/index_component.rb Updated to use new target attribute syntax
app/components/admin/enumerations/index_component.rb Updated target attribute and changed selector from & to :scope
modules/documents/app/components/documents/admin/document_types/item_component.html.erb Removed draggable: true parameter from DragHandle
app/components/work_package_types/export_template_row_component.html.erb Removed draggable: true parameter from DragHandle
app/components/admin/enumerations/item_component.html.erb Removed draggable: true parameter from DragHandle

@myabc myabc added javascript Pull requests that update Javascript code bugfix needs review labels Feb 2, 2026
@myabc myabc requested review from dombesz and mrmir February 2, 2026 22:51
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 2, 2026

Caution

The provided work package version does not match the core version

Details:

Please make sure that:

  • The work package version OR your pull request target branch is correct

Copy link
Copy Markdown
Contributor

@mrmir mrmir left a comment

Choose a reason for hiding this comment

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

The changes work everywhere. I don't know about special cases in the other areas, but at least for meetings those are handled too 👍🏽

}
end

def drag_and_drop_target_config
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks for removing this 👍🏽

@mrmir mrmir removed the needs review label Feb 3, 2026
@mrmir
Copy link
Copy Markdown
Contributor

mrmir commented Feb 3, 2026

One WP has version 17.2 set and the other none, but the branch points to 17.1, btw

@myabc myabc added this to the 17.1.x milestone Feb 3, 2026
@myabc myabc merged commit 4b4a144 into release/17.1 Feb 3, 2026
29 of 38 checks passed
@myabc myabc deleted the bug/71325-drag-and-drop-turbo-interop branch February 3, 2026 12:33
@github-actions github-actions bot locked and limited conversation to collaborators Feb 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bugfix javascript Pull requests that update Javascript code

Development

Successfully merging this pull request may close these issues.

3 participants