diff --git a/src/plugins/vis_type_table/public/components/table_vis_component.tsx b/src/plugins/vis_type_table/public/components/table_vis_component.tsx index c0e4ab61ae8b..3d7602e9a991 100644 --- a/src/plugins/vis_type_table/public/components/table_vis_component.tsx +++ b/src/plugins/vis_type_table/public/components/table_vis_component.tsx @@ -37,7 +37,7 @@ export const TableVisComponent = ({ event, uiState: { sort, setSort, colWidth, setWidth }, }: TableVisComponentProps) => { - const { rows, formattedColumns } = table; + const { rows, columns, formattedColumns } = table; const pagination = usePagination(visConfig, rows.length); @@ -59,7 +59,15 @@ export const TableVisComponent = ({ formattedColumns, ]); - const dataGridColumns = getDataGridColumns(table, event, colWidth); + const sortedTable = useMemo(() => { + return { + rows: sortedRows, + columns, + formattedColumns, + }; + }, [sortedRows, columns, formattedColumns]); + + const dataGridColumns = getDataGridColumns(sortedTable, event, colWidth); const sortedColumns = useMemo(() => { if (