Sort columns to put autocolumns last

This commit is contained in:
Andrew Kingston 2023-03-30 16:23:13 +01:00
parent 0c53e06267
commit 11dd5fc805
1 changed files with 24 additions and 14 deletions

View File

@ -63,7 +63,8 @@ export const createColumnsStores = context => {
// Update columns, removing extraneous columns and adding missing ones
columns.set(
fields.map(field => {
fields
.map(field => {
// Check if there is an existing column with this name so we can keep
// the width setting
let existing = currentColumns.find(x => x.name === field)
@ -77,6 +78,15 @@ export const createColumnsStores = context => {
visible: existing?.visible ?? true,
}
})
.sort((a, b) => {
// Sort columns to put auto columns last
let autoColA = a.schema?.autocolumn
let autoColB = b.schema?.autocolumn
if (autoColA === autoColB) {
return 0
}
return autoColA ? 1 : -1
})
)
// Update sticky column