[v10.0.x] Maintain column widths when deleting columns (#67743)
Maintain column widths when deleting columns (#67707)
(cherry picked from commit cd8b6be41d)
Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com>
This commit is contained in:
co-authored by
Victor Marin
parent
8905356e8a
commit
95a4047d9f
@@ -220,9 +220,14 @@ export const datagridReducer = (state: DatagridState, action: DatagridAction): D
|
||||
columns = [
|
||||
...updateColumnsPayload.frame.fields.map((field: Field, index: number) => {
|
||||
const displayName = getFieldDisplayName(field, updateColumnsPayload.frame);
|
||||
|
||||
// find column by field name and update width in new set. We cannot use index because
|
||||
// if a column gets deleted we don't know the correct index anymore
|
||||
const width = state.columns.find((column) => column.title === displayName)?.width;
|
||||
|
||||
return {
|
||||
title: displayName,
|
||||
width: state.columns[index]?.width ?? getCellWidth(field),
|
||||
width: width ?? getCellWidth(field),
|
||||
icon: typeToIconMap.get(field.type),
|
||||
hasMenu: isDatagridEnabled(),
|
||||
trailingRowOptions: { targetColumn: --index },
|
||||
|
||||
Reference in New Issue
Block a user