mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 01:16:31 -06:00
Maintain column widths when deleting columns (#67707)
This commit is contained in:
parent
2ecc1802e7
commit
cd8b6be41d
@ -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 },
|
||||
|
Loading…
Reference in New Issue
Block a user