Skip to main content

Module ordered_move

Module ordered_move 

Source
Expand description

One command for “move this item somewhere else in an ordered collection”.

Several widgets in this crate let the user reorder something by dragging it, and WCAG 2.2 SC 2.5.7 requires every one of them to be reachable without a drag. The four obligations that discharges it — a menu row, a keyboard chord, an AccessKit custom action, one utterance on commit — are the same four everywhere, so they are written once, here. A consumer supplies only what is genuinely its own: how its collection commits a move, and what the moved thing is called.

The consumers today are the five data views’ rows and tiles and a tab in a TabBar. engineering/docs/drag-operation-census.md lists the reordering drags that still have no command, each with what it needs; adding one is meant to be this module plus a chord, not a new implementation.

§The four moves

OrderedMove is deliberately four values and not a signed step. “Move to the far end” is not “step repeatedly”: a keyboard user pressing Alt+Home makes one model change and hears one utterance, where repeating a step would make one of each per press.

§Why a drop spec and not a destination index

OrderedMove::as_row_drop returns the (target, position) pair a pointer drop would have carried, not the destination index. The five data views commit a reorder by handing that pair to the bound source’s accept_drop / reorder_within, and the source — not the view — owns what it means. Routing the alternative through the destination index instead would be a second implementation of the same operation, and a second implementation is exactly what an alternative must not be: it can reach a different end state than the drag, which is the one failure mode a single-pointer alternative cannot have.

The destination index is still reported, because the caller needs it for what happens after the model change — following the selection, scrolling the moved thing back into view, and naming its new position in the announcement.

Structs§

RowDrop
The (target, position) pair a pointer drop would have carried, plus where the moved item ends up.

Enums§

MoveAxis
How a collection’s order reads on screen.
OrderedMove
Which way a move goes within an ordered collection.
TreeMove
A move that changes an item’s parent rather than its position among its siblings.

Functions§

move_announcement
The one utterance a completed move makes.
reparent_announcement
The one utterance a completed reparent makes.