An ordered list is a list of rows the user drags into order. OrderedList gives each row a drag handle.
A drop, or a keyboard move from the handle, calls onMove with the old and the new index. You then update your state.
Each part handles keyboard navigation and the current and selected states. Each part also sets its own spacing, so put
the list in a panelโs body with no padding around it.
getLabel names each row for screen readers as it moves. The child of OrderedList.Root is a function of the items,
so the rows always follow the order you hold.
Example (Reordering an agenda)
1
import {
functionuseCallback<TextendsFunction>(callback: T, deps: React.DependencyList): T
useCallback will return a memoized version of the callback that only changes if one of the inputs
has changed.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
@param โ start The zero-based location in the array from which to start removing elements.
@param โ deleteCount The number of elements to remove. Omitting this argument will remove all elements from the start
paramater location to end of the array. If value of this argument is either a negative number, zero, undefined, or a type
that cannot be converted to an integer, the function will evaluate the argument as zero and not remove any elements.
@returns โ An array containing the elements that were deleted.
Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
@param โ start The zero-based location in the array from which to start removing elements.
@param โ deleteCount The number of elements to remove. If value of this argument is either a negative number, zero,
undefined, or a type that cannot be converted to an integer, the function will evaluate the argument as zero and
not remove any elements.
@param โ items Elements to insert into the array in place of the deleted elements.
@returns โ An array containing the elements that were deleted.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param โ callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param โ thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Takes a row out of a list without destroying what it names; the glyph is Close's, the intent Delete's. In a list row
it is named by its label followed by the row's ItemText ("Delete Q3 budget"); a label replaces both.
Returns the elements of an array that meet the condition specified in a callback function.
@param โ predicate A function that accepts up to three arguments. The filter method calls the predicate function one time for each element in the array.
@param โ thisArg An object to which the this keyword can refer in the predicate function. If thisArg is omitted, undefined is used as the this value.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.
Reorderable list on Listbox, sharing its row vocabulary: rows are Items composed from a DragHandle,
ItemIcon, ItemText and trailing controls; a collapsible Item adds a caret and a Detail. The ARIA grid keyboard
enters a row with ArrowRight, where the DragHandle moves it with Alt+ArrowUp/Down.