Commit f05cc6d34e935c342e1f7ada6692ea0178b7c984
Committed by
GitHub
1 parent
8b5cbca3
fix(useColumn): fixed table column changes with hidden columns disappearing after dropping (#453)
Co-authored-by: Alan <alan@ichestnuts.com>
Showing
1 changed file
with
7 additions
and
2 deletions
src/components/Table/src/hooks/useColumns.ts
@@ -207,6 +207,11 @@ export function useColumns( | @@ -207,6 +207,11 @@ export function useColumns( | ||
207 | ...item, | 207 | ...item, |
208 | defaultHidden: false, | 208 | defaultHidden: false, |
209 | }); | 209 | }); |
210 | + } else { | ||
211 | + newColumns.push({ | ||
212 | + ...item, | ||
213 | + defaultHidden: true, | ||
214 | + }); | ||
210 | } | 215 | } |
211 | }); | 216 | }); |
212 | 217 | ||
@@ -214,8 +219,8 @@ export function useColumns( | @@ -214,8 +219,8 @@ export function useColumns( | ||
214 | if (!isEqual(cacheKeys, columns)) { | 219 | if (!isEqual(cacheKeys, columns)) { |
215 | newColumns.sort((prev, next) => { | 220 | newColumns.sort((prev, next) => { |
216 | return ( | 221 | return ( |
217 | - columnKeys.indexOf(prev.dataIndex as string) - | ||
218 | - columnKeys.indexOf(next.dataIndex as string) | 222 | + cacheKeys.indexOf(prev.dataIndex as string) - |
223 | + cacheKeys.indexOf(next.dataIndex as string) | ||
219 | ); | 224 | ); |
220 | }); | 225 | }); |
221 | } | 226 | } |