From 92676b4654a4bd9543b0858260c51ea7cf5d3528 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Claud=C3=A9ric=20Demers?= Date: Sat, 21 Sep 2024 09:26:14 -0400 Subject: [PATCH] Use optimistic sorting for columns --- .../react/Sortable/MultipleLists/MultipleLists.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/stories/stories/react/Sortable/MultipleLists/MultipleLists.tsx b/apps/stories/stories/react/Sortable/MultipleLists/MultipleLists.tsx index f8effa97..497d4c7d 100644 --- a/apps/stories/stories/react/Sortable/MultipleLists/MultipleLists.tsx +++ b/apps/stories/stories/react/Sortable/MultipleLists/MultipleLists.tsx @@ -63,15 +63,23 @@ export function MultipleLists({ } if (source.type === 'column') { - setColumns((columns) => move(columns, source, target)); + // We can rely on optimistic sorting for columns return; } + event.preventDefault(); setItems((items) => move(items, source, target)); }} onDragEnd={(event) => { if (event.canceled) { setItems(snapshot.current); + return; + } + + const {source, target} = event.operation; + + if (source?.type === 'column') { + setColumns((columns) => move(columns, source, target)); } }} >