fix potential stale state on list config reorder, slight redesign

This commit is contained in:
jeffvli
2025-12-02 17:40:00 -08:00
parent 7701ea0a8c
commit d22b24d98f
4 changed files with 22 additions and 11 deletions
@@ -404,7 +404,10 @@ const GridRowConfig = ({
const handleReorder = useCallback(
(idFrom: string, idTo: string, edge: Edge | null) => {
const idList = value.map((item) => item.id);
const currentValue = useSettingsStore.getState().lists[listKey]?.grid.rows;
if (!currentValue) return;
const idList = currentValue.map((item) => item.id);
const newIdOrder = dndUtils.reorderById({
edge,
idFrom,
@@ -413,10 +416,10 @@ const GridRowConfig = ({
});
// Map the new ID order back to full items
const newOrder = newIdOrder.map((id) => value.find((item) => item.id === id)!);
const newOrder = newIdOrder.map((id) => currentValue.find((item) => item.id === id)!);
onChange(newOrder);
},
[onChange, value],
[listKey, onChange],
);
return (