Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(table): fix column dragger problem #1730

Merged
merged 1 commit into from Jan 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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