Skip to content

Commit 5a8f9fb

Browse files
committed
fix(table): restrict movement to only the vertical axis.
close #7477
1 parent 870cfbe commit 5a8f9fb

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

packages/table/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"@ant-design/pro-utils": "2.12.8",
4343
"@babel/runtime": "^7.18.0",
4444
"@dnd-kit/core": "^6.0.8",
45+
"@dnd-kit/modifiers": "^6.0.1",
4546
"@dnd-kit/sortable": "^7.0.2",
4647
"@dnd-kit/utilities": "^3.2.1",
4748
"classnames": "^2.3.2",

packages/table/src/utils/useDragSort.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
useSensor,
99
useSensors,
1010
} from '@dnd-kit/core';
11+
import { restrictToVerticalAxis } from '@dnd-kit/modifiers';
1112
import {
1213
arrayMove,
1314
SortableContext,
@@ -180,6 +181,7 @@ export function useDragSort<T>(props: UseDragSortOptions<T>) {
180181
DndContext: (contextProps: any) => {
181182
return (
182183
<DndContext
184+
modifiers={[restrictToVerticalAxis]}
183185
sensors={sensors}
184186
collisionDetection={closestCenter}
185187
onDragEnd={handleDragEnd}

pnpm-lock.yaml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)