From 10f93cf70da3048052bd925dddc8af4d7068ce74 Mon Sep 17 00:00:00 2001 From: winerlu Date: Sat, 16 Jan 2021 13:17:45 +0800 Subject: [PATCH] fix(table): fix column insertion disorder BUG fix #1285 --- packages/table/src/store/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/table/src/store/index.ts b/packages/table/src/store/index.ts index 238a4214a3..574bb4719f 100644 --- a/packages/table/src/store/index.ts +++ b/packages/table/src/store/index.ts @@ -48,7 +48,15 @@ function useStore(): Store { const array = unref(states._columns) if (!parent) { - array.splice(index, 0, column) + if (array.length > index && (array[index] !== undefined)) { + array.splice(index, 0, column) + const nearlyEmptyIndex = array.findIndex((item, i) => i > index && item === undefined) + if (nearlyEmptyIndex > -1) { + array.splice(nearlyEmptyIndex, 1) + } + } else { + array[index] = column + } states._columns.value = array } else { if (parent && !parent.children) { @@ -62,7 +70,6 @@ function useStore(): Store { states.selectable.value = column.selectable states.reserveSelection.value = column.reserveSelection } - if (instance.$ready) { instance.store.updateColumns() // hack for dynamics insert column instance.store.scheduleLayout()