Skip to content

Commit

Permalink
fix(table): fix column dragger problem
Browse files Browse the repository at this point in the history
  • Loading branch information
ChenCheng220 committed Jan 22, 2021
1 parent 6d0fa40 commit 5ddbe4a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/table/src/components/ColumnSetting/index.tsx
Expand Up @@ -112,7 +112,7 @@ const CheckboxList: React.FC<{
const newColumns = [...sortKeyColumns.current];
const findIndex = newColumns.findIndex((columnKey) => columnKey === id);
const targetIndex = newColumns.findIndex((columnKey) => columnKey === targetId);
const isBottom = dropPosition > targetIndex;
const isDownword = dropPosition > findIndex;
if (findIndex < 0) {
return;
}
Expand All @@ -121,7 +121,7 @@ const CheckboxList: React.FC<{
if (dropPosition === 0) {
newColumns.unshift(targetItem);
} else {
newColumns.splice(isBottom ? targetIndex + 1 : targetIndex, 0, targetItem);
newColumns.splice(isDownword ? targetIndex : targetIndex + 1, 0, targetItem);
}
// 重新生成排序数组
newColumns.forEach((key, order) => {
Expand Down Expand Up @@ -156,7 +156,9 @@ const CheckboxList: React.FC<{
onDrop={(info) => {
const dropKey = info.node.key;
const dragKey = info.dragNode.key;
move(dragKey, dropKey, info.dropPosition);
const { dropPosition, dropToGap } = info;
const position = dropPosition === -1 || !dropToGap ? dropPosition + 1 : dropPosition;
move(dragKey, dropKey, position);
}}
blockNode
onCheck={(_, e) => {
Expand Down

0 comments on commit 5ddbe4a

Please sign in to comment.