Skip to content

Commit

Permalink
[Bug][Table Visualization] Fix first column sort issue (#2828)
Browse files Browse the repository at this point in the history
Currently, the first column of table vis won't sort. This PR fixes
the bug.

Issue Resolved:
#2827

Signed-off-by: Anan Zhuang <[email protected]>

Signed-off-by: Anan Zhuang <[email protected]>
(cherry picked from commit f12fa98)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md
  • Loading branch information
github-actions[bot] committed Nov 9, 2022
1 parent 7805904 commit a2ce559
Showing 1 changed file with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ export const TableVisComponent = ({
const pagination = usePagination(visConfig, rows.length);

const sortedRows = useMemo(() => {
return uiState.sort?.colIndex && uiState.sort.direction
? orderBy(rows, columns[uiState.sort.colIndex]?.id, uiState.sort.direction)
return uiState.sort.colIndex !== null &&
columns[uiState.sort.colIndex].id &&
uiState.sort.direction
? orderBy(rows, columns[uiState.sort.colIndex].id, uiState.sort.direction)
: rows;
}, [columns, rows, uiState]);

Expand All @@ -58,8 +60,10 @@ export const TableVisComponent = ({
const dataGridColumns = getDataGridColumns(sortedRows, columns, table, event, uiState.width);

const sortedColumns = useMemo(() => {
return uiState.sort?.colIndex && uiState.sort.direction
? [{ id: dataGridColumns[uiState.sort.colIndex]?.id, direction: uiState.sort.direction }]
return uiState.sort.colIndex !== null &&
dataGridColumns[uiState.sort.colIndex].id &&
uiState.sort.direction
? [{ id: dataGridColumns[uiState.sort.colIndex].id, direction: uiState.sort.direction }]
: [];
}, [dataGridColumns, uiState]);

Expand Down

0 comments on commit a2ce559

Please sign in to comment.