Use it when the reorder logic is yours, as in a document editor or a data table. For a plain vertical list, NbReorderList already owns the whole job.
Tab to a handle, press Space, move with the arrow keys, and press Space again to drop.
<template>
<div v-for="(block, index) in blocks" :key="block.id" class="block">
<NbDragHandle
:label="`Move ${block.label}`"
:announcement="announcement"
@drag-start="onStart(index, $event)"
@drag-move="onMove(index, $event)"
@drag-end="onDrop"
@drag-cancel="onCancel"
/>
{{ block.label }}
</div>
</template>The drag lifecycle
Every way of dragging reports the same four events, each with an IDragHandleEvent whose via says what drove it.
| Event | Pointer | Keyboard | Native (native) |
|---|---|---|---|
drag-start | Pointer travelled past threshold | Space or Enter | dragstart |
drag-move | Every pointer move | Each arrow key along axis | (use your drop target) |
drag-end | Pointer released | Space / Enter, or focus left | dragend with a drop |
drag-cancel | Escape or pointercancel | Escape | dragend without a drop |
For a pointer, deltaX and deltaY are pixels from where the press started, and clientX / clientY are the pointer. For the keyboard they count arrow-key steps since pick-up, and direction names the step just taken. A host that reorders live can act on direction. One that previews and commits on drop can use the deltas.
A press that never travels past threshold stays a plain click, so a handle can also open a block menu on click. A press that did become a drag does not also fire click.
Axis
axis picks the glyph and the arrow keys. A handle for a row or a block uses vertical (the default), a column handle uses horizontal, and a free-floating item uses both.
Announcing moves
A keyboard user does not see the item travel. The handle cannot know the new position, because it does not own the reorder, so it gives you a polite live region instead: set announcement after each move ("Introduction moved to position 3 of 5") and it is read out.
Hosts that move DOM nodes
A browser drops focus from a node when that node is moved, which is exactly what a keyed list does when the host reorders on drag-move. The handle recognises that blur (focus went nowhere and nothing was clicked) and takes focus back, so the item stays held. A blur to another control, or a click elsewhere, drops the item, the same as NbReorderList.