Skip to content

Extras

Sortable

Bit.BlazorUI.ExtrasSortableListReorderableListDragAndDropList

BitSortable is a drag-and-drop sortable list, inspired by SortableJS: reorder the items of a list, or drag them between lists that share a Group - with live reordering, slide animations, clone and move pull modes, swap thresholds, drag handles, filters, nested lists, swap mode, multi-drag and the keyboard, every step announced to screen readers.

Keyboard, touch & performance

Dragging by keyboard with localized announcements, touch and pen input, a large list, and telling items apart with ItemKey.

Keyboard & Strings

With Keyboard on (the default) a list is one tab stop: the arrow keys move between its items, Space or Enter picks the focused one up, the arrows move it - into the next list of the group too - Home and End to the ends, Space or Enter drops it and Escape puts it back. Every step is announced, naming the item by ItemLabel and the list by its AriaLabel. Strings rewords or translates what is announced.
  • Tab enters the list at the item focused last; during a keyboard drag it drops the item where it is, and moves on.
  • The arrow keys move the focus to the item in that direction; during a drag they move the item to the next place that way and, past the end of its list, into the nearest list of the group in that direction (here, the right arrow from the Backlog carries an item into the Sprint).
  • Home and End focus the first and the last item; during a drag they move the item to the start or the end of its list.
  • Space or Enter picks the focused item up, and drops it. Escape puts it back where it was.
  • Shift+Space selects or deselects the focused item of a MultiDrag list.
  • The arrows follow the layout - up and down a vertical list, along a row, right to left in a right-to-left one, row to row in a grid, from column to column of a board, into a nested list - because the next item, or list, is looked for in the direction of the key.
  • A keyboard drag moves the item itself, into another list too, and the focus follows it. Every rule applies as for a pointer: a refused position, a full list or a list of another group is announced as refused, ConfirmDrop is asked on the drop, and in Swap mode the arrows move the highlight.
  • Keys pressed inside an item - on a button, in an input - are left to it: only an item itself, or its drag handle, answers them. Keyboard="false" turns it all off, and a Disabled list is not focusable.
  • A list is a list of listitems, each described as a "sortable item" (RoleDescription) and pointing to the keyboard instructions (Instructions, through aria-describedby), and named by AriaLabel. Each step is announced through a live region with the item's name, its position and the list it is in; a pointer drag is announced when it starts and when it ends. A drag is announced in the Strings of the list it started in. The texts are functions of a BitSortableAnnouncement, and can be set for every list at once through a BitSortableParams.
  • The focus outline of an item, and the dashed one of an item picked up, are drawn in forced colors (Windows high contrast) too.

Backlog
#1 Sign-up page
#2 Password reset
#3 Audit log
Sprint
#4 Search
#5 Export to CSV

Touch & pen

A finger drags an item after resting on it for TouchDelay milliseconds, so a swipe over the list still scrolls the page; Delay is the same wait for the mouse and the pen. A pointer that moves more than DelayTolerance pixels first is a scroll or a click instead. With ForceFallback the mouse drags the way a finger does, with a preview of the item that follows it, instead of the browser's own drag image.
  • A mouse drags with the browser's own HTML5 drag and drop, as SortableJS does on the desktop. A finger or a pen drags with pointer events, which work the same in every browser and web view, whether or not it supports HTML5 drag and drop on touch: the item stays in its list, dimmed, while a copy of it follows the pointer. Both feed the same hit test and raise the same events, with Input saying which it was. ForceFallback is also for a web view whose native drag and drop does not work.
  • Once a finger drags an item the page does not scroll under it; near an edge, the drag scrolls the list, a panel around it or the page (see Large list).
  • Escape, a system gesture that takes the pointer over, or leaving the page cancels a pointer drag and puts everything back. The click a browser sends after a press is swallowed after a drag, so dropping an item does not also click it, and a press on a control inside an item - a button, a link, an input - is left to the control.
  • The preview is a copy of the item placed above the page, in the Drag part: --bit-Sortable-drag-opacity and --bit-Sortable-drag-shadow restyle it, set on :root since the preview is outside the list.
  • In the second list a finger on the grip drags at once: the handle has touch-action: none, so the browser does not scroll from it, and TouchDelay is 0. The rest of the row still scrolls the page.

Long press
Kale
Lemons
Milk
Nuts
Oats
Handle, at once
Dishes
Laundry
Plants
Recycling

Large list

Three hundred rows in a scrolling panel. Drag a row toward the panel's edge and it scrolls: the browser scrolls for the mouse's own drag, the list for a finger, a pen or a ForceFallback mouse - when Scroll is on, within ScrollSensitivity pixels of the edge and at up to ScrollSpeed pixels a frame, faster the closer the pointer is to the edge. IsolateItems renders each row's template in a component of its own, which a step of the drag does not render again.
  • The pointer is followed and measured in the browser: a step that does not change the drop position never reaches .NET, and one that does is a single call - while it is on its way the browser keeps the latest position for when it returns, so no position is lost and none queues up. That keeps a drag smooth on Blazor Server too.
  • A new position changes the bound list in place and renders the list once, and the browser slides the rows when that render lands. A render of the list renders all its items' templates; with IsolateItems only the wrappers move. Leave it off when a template shows something that other items' moves change, such as the item's position number: that would only catch up when the drag ends.
  • From the keyboard, pick Row 1 up and hold the down arrow: the row walks down, and the panel follows it into view.
  • In the browser's console, BitBlazorUI.Sortable.diagnostics() after a drag shows the positions sent to .NET - one per row crossed, not one per pointer move - and the average and slowest round trip; BitBlazorUI.Sortable.resetDiagnostics() starts over.
  • A list renders every item it is given: Blazor's Virtualize is not supported, since rows that are not rendered could be neither measured nor dropped beside. Page a list that is too long to render, or let a filter narrow it.

Row 1 open
Row 2 in review
Row 3 blocked
Row 4 in review
Row 5 open
Row 6 blocked
Row 7 open
Row 8 in review
Row 9 blocked
Row 10 in review
Row 11 open
Row 12 blocked
Row 13 open
Row 14 in review
Row 15 blocked
Row 16 in review
Row 17 open
Row 18 blocked
Row 19 open
Row 20 in review
Row 21 blocked
Row 22 in review
Row 23 open
Row 24 blocked
Row 25 open
Row 26 in review
Row 27 blocked
Row 28 in review
Row 29 open
Row 30 blocked
Row 31 open
Row 32 in review
Row 33 blocked
Row 34 in review
Row 35 open
Row 36 blocked
Row 37 open
Row 38 in review
Row 39 blocked
Row 40 in review
Row 41 open
Row 42 blocked
Row 43 open
Row 44 in review
Row 45 blocked
Row 46 in review
Row 47 open
Row 48 blocked
Row 49 open
Row 50 in review
Row 51 blocked
Row 52 in review
Row 53 open
Row 54 blocked
Row 55 open
Row 56 in review
Row 57 blocked
Row 58 in review
Row 59 open
Row 60 blocked
Row 61 open
Row 62 in review
Row 63 blocked
Row 64 in review
Row 65 open
Row 66 blocked
Row 67 open
Row 68 in review
Row 69 blocked
Row 70 in review
Row 71 open
Row 72 blocked
Row 73 open
Row 74 in review
Row 75 blocked
Row 76 in review
Row 77 open
Row 78 blocked
Row 79 open
Row 80 in review
Row 81 blocked
Row 82 in review
Row 83 open
Row 84 blocked
Row 85 open
Row 86 in review
Row 87 blocked
Row 88 in review
Row 89 open
Row 90 blocked
Row 91 open
Row 92 in review
Row 93 blocked
Row 94 in review
Row 95 open
Row 96 blocked
Row 97 open
Row 98 in review
Row 99 blocked
Row 100 in review
Row 101 open
Row 102 blocked
Row 103 open
Row 104 in review
Row 105 blocked
Row 106 in review
Row 107 open
Row 108 blocked
Row 109 open
Row 110 in review
Row 111 blocked
Row 112 in review
Row 113 open
Row 114 blocked
Row 115 open
Row 116 in review
Row 117 blocked
Row 118 in review
Row 119 open
Row 120 blocked
Row 121 open
Row 122 in review
Row 123 blocked
Row 124 in review
Row 125 open
Row 126 blocked
Row 127 open
Row 128 in review
Row 129 blocked
Row 130 in review
Row 131 open
Row 132 blocked
Row 133 open
Row 134 in review
Row 135 blocked
Row 136 in review
Row 137 open
Row 138 blocked
Row 139 open
Row 140 in review
Row 141 blocked
Row 142 in review
Row 143 open
Row 144 blocked
Row 145 open
Row 146 in review
Row 147 blocked
Row 148 in review
Row 149 open
Row 150 blocked
Row 151 open
Row 152 in review
Row 153 blocked
Row 154 in review
Row 155 open
Row 156 blocked
Row 157 open
Row 158 in review
Row 159 blocked
Row 160 in review
Row 161 open
Row 162 blocked
Row 163 open
Row 164 in review
Row 165 blocked
Row 166 in review
Row 167 open
Row 168 blocked
Row 169 open
Row 170 in review
Row 171 blocked
Row 172 in review
Row 173 open
Row 174 blocked
Row 175 open
Row 176 in review
Row 177 blocked
Row 178 in review
Row 179 open
Row 180 blocked
Row 181 open
Row 182 in review
Row 183 blocked
Row 184 in review
Row 185 open
Row 186 blocked
Row 187 open
Row 188 in review
Row 189 blocked
Row 190 in review
Row 191 open
Row 192 blocked
Row 193 open
Row 194 in review
Row 195 blocked
Row 196 in review
Row 197 open
Row 198 blocked
Row 199 open
Row 200 in review
Row 201 blocked
Row 202 in review
Row 203 open
Row 204 blocked
Row 205 open
Row 206 in review
Row 207 blocked
Row 208 in review
Row 209 open
Row 210 blocked
Row 211 open
Row 212 in review
Row 213 blocked
Row 214 in review
Row 215 open
Row 216 blocked
Row 217 open
Row 218 in review
Row 219 blocked
Row 220 in review
Row 221 open
Row 222 blocked
Row 223 open
Row 224 in review
Row 225 blocked
Row 226 in review
Row 227 open
Row 228 blocked
Row 229 open
Row 230 in review
Row 231 blocked
Row 232 in review
Row 233 open
Row 234 blocked
Row 235 open
Row 236 in review
Row 237 blocked
Row 238 in review
Row 239 open
Row 240 blocked
Row 241 open
Row 242 in review
Row 243 blocked
Row 244 in review
Row 245 open
Row 246 blocked
Row 247 open
Row 248 in review
Row 249 blocked
Row 250 in review
Row 251 open
Row 252 blocked
Row 253 open
Row 254 in review
Row 255 blocked
Row 256 in review
Row 257 open
Row 258 blocked
Row 259 open
Row 260 in review
Row 261 blocked
Row 262 in review
Row 263 open
Row 264 blocked
Row 265 open
Row 266 in review
Row 267 blocked
Row 268 in review
Row 269 open
Row 270 blocked
Row 271 open
Row 272 in review
Row 273 blocked
Row 274 in review
Row 275 open
Row 276 blocked
Row 277 open
Row 278 in review
Row 279 blocked
Row 280 in review
Row 281 open
Row 282 blocked
Row 283 open
Row 284 in review
Row 285 blocked
Row 286 in review
Row 287 open
Row 288 blocked
Row 289 open
Row 290 in review
Row 291 blocked
Row 292 in review
Row 293 open
Row 294 blocked
Row 295 open
Row 296 in review
Row 297 blocked
Row 298 in review
Row 299 open
Row 300 blocked

ItemKey

ItemKey says what identifies an item - its id - for rows that a server sends again as new objects. Select two rows and load them again: with ItemKey they keep their elements, their focus and their selection, and a drag moves the object the list holds now; without it, the new objects are new items to the list, and the selection is gone. The key must be unique within the list and stay the same while the row is in it. It is also how the list spots a duplicate: a row whose key is already in a list is never dropped into it, so a Clone factory gives a copy a key of its own. A lambda written inline is fine: the list tells a new ItemKey by its code, not by the delegate a render creates.

Write the spec
Review the design
Build the API
Ship it
Loaded 1 time(s)

Feedback

Found a mistake, a gap, or something that could be clearer? Every page and every component is one click from its source.