You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, I am not sure if we need to support controlled / uncontrolled behavior (internal state of the ordering) for this component. This case is similar to component like DropzoneAccepted in which render props is required to render based on the internal state of the component, albeit most of the time we don't need to use that component.
This example was taken from my previous Sortable implementation:
<SortabledefaultItems={['id-001','id-002','id-003','id-004']}>
// Feels a little awkward here, do we need to support this API?
{(items)=>(<ulclassName="grid gap-4">{items.map((item)=>(<SortableItemkey={item}id={item}><liclassName="flex items-center justify-center gap-4 rounded-md border bg-background py-2 pl-2 pr-4"><SortableItemActivatorGripIconButton/><pclassName="text-sm text-muted-foreground">{item}</p></li></SortableItem>))}</ul>)}</Sortable>
I am wondering if we don't even need to support having items as it's state, and instead just exposes prop like onReorder and allow outside to control the ordering of the list, would be a better choice.
I am currently leaning towards keeping the API simpler by removing the items, defaultItems and onItemsChange API. Axis can also be locked via modifier.
Sortable
Utility component that allows sorting of elements.
Description
I've built this component before, which had props like
However, I am not sure if we need to support controlled / uncontrolled behavior (internal state of the ordering) for this component. This case is similar to component like
DropzoneAccepted
in which render props is required to render based on the internal state of the component, albeit most of the time we don't need to use that component.This example was taken from my previous
Sortable
implementation:I am wondering if we don't even need to support having
items
as it's state, and instead just exposes prop likeonReorder
and allow outside to control the ordering of the list, would be a better choice.I am currently leaning towards keeping the API simpler by removing the
items
,defaultItems
andonItemsChange
API.Axis
can also be locked via modifier.Anatomy
Libraries / Hooks
The text was updated successfully, but these errors were encountered: