Drag handles
Let items be dragged only from a grip, so the rest of each item stays free for text selection and clicks.
By default the whole item starts a drag. With drag handles, only an element you mark inside each item does. Use dragHandleZone instead of dndzone on the container, and {@attach dragHandle} on the handle:
dragHandleZone takes the same options as dndzone, and calls onconsider and onfinalize the same way.
How handles behave
- An item of a
dragHandleZonecan only be dragged from a handle inside it. The handle does not have to be a direct child of the item, but it has to be inside it. An item without a handle cannot be dragged. - The handle starts a drag with the mouse, a touch, or the keyboard drag trigger (Space or Enter by default, see keyboard and screen readers).
- The handle gets
role="button", is a tab stop, and shows agrabcursor. The items themselves are not tab stops in a handle zone, so the keyboard reaches the handles instead. Give each handle anaria-label, because a screen reader announces it as a button. dragDisabledon a handle zone turns off the handles of that zone only. Its handles leave the tab order and lose thegrabcursor.- A handle outside of any
dragHandleZonedoes nothing. Withconfigure({ debug: true })the library logs it when the handle is removed.
Nested handle zones
A handle belongs to the nearest handle zone around it. So a list of groups, where each group is a handle zone of tasks, works without extra setup: the grip of a group drags the group, and the grip of a task drags the task. The drag handles demo is such a list. Give the two levels different types, as with any nested zones, so a task cannot land between the groups.
See the API reference for both attachments.