mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 11:53:09 +08:00
Table: Prevent runtime error when resizing columns with onColumnResize (#89862)
fix: prevent runtime error when resizing columns
This commit is contained in:
@ -15,12 +15,12 @@ export function useTableStateReducer({ onColumnResize, onSortByChange, data }: P
|
|||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'columnDoneResizing':
|
case 'columnDoneResizing':
|
||||||
if (onColumnResize) {
|
if (onColumnResize) {
|
||||||
const info = (newState.columnResizing.headerIdWidths as any)[0];
|
const info = (newState.columnResizing?.headerIdWidths as any)?.[0];
|
||||||
const columnIdString = info[0];
|
const columnIdString = info?.[0];
|
||||||
const fieldIndex = parseInt(columnIdString, 10);
|
const fieldIndex = parseInt(columnIdString, 10);
|
||||||
const width = Math.round(newState.columnResizing.columnWidths[columnIdString]);
|
const width = Math.round(newState.columnResizing.columnWidths?.[columnIdString]);
|
||||||
|
|
||||||
const field = data.fields[fieldIndex];
|
const field = data.fields?.[fieldIndex];
|
||||||
if (!field) {
|
if (!field) {
|
||||||
return newState;
|
return newState;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user