Support Grid Item Movement via External Element (outside Grid) Drag #3024
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This pull request adds support for moving grid items when drag events are initiated from elements outside the grid. This enhancement allows developers to implement more interactive interfaces, such as custom drag handles or external controls that reposition grid items without direct interaction with the grid itself.
A specific scenario motivating this enhancement involves grid item titles that are displayed as popups when hovering over a grid item. These popup elements are appended to the HTML body (or a similar general DOM container) as per standard best practices for creating tooltips or popups, ensuring proper rendering and positioning. Since these popups exist outside the grid item’s DOM hierarchy, they cannot inherently trigger grid item movement.
To address this limitation, the grid’s drag-and-drop functionality has been extended to support external elements. This feature allows developers to dynamically reference and use such external elements (e.g., popup titles) as drag handles for moving grid items.
This solution leverages existing drag-and-drop infrastructure, ensuring seamless integration without introducing additional complexity.
A new demo, "Title Drag from Outside GridStack Item", has been added to illustrate this use case and demonstrate the versatility of this enhancement.
Checklist
yarn test)