Component
Task list (sortable)
Published on
Description
A sortable task list adds a sort select, and an optional add link, above a Task list. The ds-task-sortable web component listens for changes on the select and reorders the rows by their data-sort-* attributes.
The first option must be the order the server already rendered. Without JavaScript the list still shows in that order, only the select does nothing.
Each option value names a sort key; prefix it with - for descending. Give rows machine values to sort by, such as epoch milliseconds or ordinals, rather than the localized text they display.
Example
Accessibility
- The select has no visible label;
aria-labelnames the collapsed control and the<optgroup>label repeats it when the list is open. - Reordering moves the existing
<li>nodes, so focus and any state on a row are kept. - Each row keeps a single click target; the controls sit outside the list.
References
Related
Variables
tasks— rows, as for Task list, with asortobject rendered asdata-sort-*sorts— the options, each with avalueand alabelsortLabel— defaults toSort byaddHrefandaddLabel— optional add link