From 3c8fd871aa788f918f6bd879c153929b4c63e7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rge=20N=C3=A6ss?= Date: Fri, 16 Dec 2022 13:38:41 +0100 Subject: [PATCH] fix(form): set sorting strategy for list axis --- .../List/ListArrayInput.tsx | 1 + .../core/form/inputs/arrays/common/list.tsx | 28 ++++++++++++------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/sanity/src/core/form/inputs/arrays/ArrayOfObjectsInput/List/ListArrayInput.tsx b/packages/sanity/src/core/form/inputs/arrays/ArrayOfObjectsInput/List/ListArrayInput.tsx index c1def187c73..204ab3f8b7b 100644 --- a/packages/sanity/src/core/form/inputs/arrays/ArrayOfObjectsInput/List/ListArrayInput.tsx +++ b/packages/sanity/src/core/form/inputs/arrays/ArrayOfObjectsInput/List/ListArrayInput.tsx @@ -66,6 +66,7 @@ export function ListArrayInput(props: ArrayOfObjectsInp ) : ( [ - restrictToParentElementWithMargins({y: 4}), - ...(lockAxis ? [restrictToAxis(lockAxis)] : []), - ], - [lockAxis] + () => [restrictToParentElementWithMargins({y: 4}), ...(axis ? [restrictToAxis(axis)] : [])], + [axis] ) return ( @@ -81,7 +89,7 @@ function SortableList(props: ListProps) { collisionDetection={closestCenter} onDragEnd={handleDragEnd} > - + {children} @@ -120,7 +128,7 @@ function SortableListItem(props: ItemProps) { interface ListProps extends ComponentProps { sortable?: boolean - lockAxis?: 'x' | 'y' + axis?: Axis items: string[] onItemMove?: (event: {fromIndex: number; toIndex: number}) => void children?: React.ReactNode