From f05cc6d34e935c342e1f7ada6692ea0178b7c984 Mon Sep 17 00:00:00 2001 From: qinjiahui01 <39482111+qinjiahui01@users.noreply.github.com> Date: Wed, 7 Apr 2021 23:39:08 +0800 Subject: [PATCH] fix(useColumn): fixed table column changes with hidden columns disappearing after dropping (#453) Co-authored-by: Alan --- src/components/Table/src/hooks/useColumns.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/Table/src/hooks/useColumns.ts b/src/components/Table/src/hooks/useColumns.ts index 631a66d05..7a53db91d 100644 --- a/src/components/Table/src/hooks/useColumns.ts +++ b/src/components/Table/src/hooks/useColumns.ts @@ -207,6 +207,11 @@ export function useColumns( ...item, defaultHidden: false, }); + } else { + newColumns.push({ + ...item, + defaultHidden: true, + }); } }); @@ -214,8 +219,8 @@ export function useColumns( if (!isEqual(cacheKeys, columns)) { newColumns.sort((prev, next) => { return ( - columnKeys.indexOf(prev.dataIndex as string) - - columnKeys.indexOf(next.dataIndex as string) + cacheKeys.indexOf(prev.dataIndex as string) - + cacheKeys.indexOf(next.dataIndex as string) ); }); }