Shared lists
Lists with the same Group name exchange items: drag an item from one list into the other, onto an
item or into the empty space of a list. While it is over the other list a placeholder shows where it will land,
and the item moves for good when you drop it.
Two lists, one group
Both lists have Group="shared". The "B" items keep their tint wherever they go: the class comes
from ItemClassSelector, which computes it from the item rather than from the list it is in - and
the drop placeholder wears it too, so the preview looks like the item will.
A:
B:
Into an empty list
A list keeps an area to drop into when it is empty, as long as it has some height: here, the padding and the
min-height of its class. ChildContent - whatever you put inside the
<Bortable> tag next to ItemTemplate - is rendered after the items, which is
where an empty state goes. It is inside the list, so it carries role="listitem" and is read as part
of it; this page's stylesheet hides it while the list previews an item.
Inbox:
Archive:
Try it
-
Drag A2 over List B: a dashed placeholder shows where it will land, and the original disappears from
List A. Drop it, and both lines under the lists change - each list's
ItemsChangedis raised once. -
Drag an item over the other list, then back over its own: the preview goes away and the item is back home.
Released with the mouse outside every list, an item previewed in another one lands there, as in SortableJS -
the rules page shows
RevertOnSpill, which puts it back instead. - Move every message out of the Inbox: its empty state shows up, and the Inbox still takes items back.
- From the keyboard, pick A2 up with Space and press →: List A has no item to its right, so the item is carried into List B, the nearest list of the group in that direction. Space drops it there.
How it works
-
Over another list the item is not moved yet: that list renders a placeholder - the item's own template, with
the ghost class - where it would land, and the source hides its original (
bit-bortable-hidden). The item moves between the lists when the drag ends, because moving a DOM node from one component to another would recreate it and cancel the browser's drag. (A keyboard drag moves the item itself.) -
Which lists exchange items is decided per list:
Pullsays how items leave it (Move, the default,CloneorNone) andPutwhether items of the group may enter it. See cloning and disabling sorting. -
An item is only offered to lists of its own
TItem, and never to a list that already holds an equal item (two lists of strings cannot both hold "A1"). Lists of other item types may share the group; they simply ignore each other's items. -
Give the lists an
Idof your own when your code needs to tell them apart: the events report it asFromIdandToId.
Parameters on this page
| Parameter | Here | What it does |
|---|---|---|
Group | shared, shared-empty | Lists with the same group name exchange items. |
ItemClassSelector | Tint | A class computed from the item, added to its wrapper, so it follows the item from list to list. |
ChildContent | the empty states | Extra content rendered inside the list, after the items. |
AriaLabel | Inbox, Archive | The list's accessible name, which announcements name it by: "moved to position 1 of 3 in Archive". |