Skip to content

Commit

Permalink
[Bug][Table Visualization] Fix first column sort issue (opensearch-pr…
Browse files Browse the repository at this point in the history
…oject#2828)

Currently, the first column of table vis won't sort. This PR fixes
the bug.

Issue Resolved:
opensearch-project#2827

Signed-off-by: Anan Zhuang <ananzh@amazon.com>

Signed-off-by: Anan Zhuang <ananzh@amazon.com>
Signed-off-by: Arpit Bandejiya <abandeji@amazon.com>
  • Loading branch information
ananzh authored and Arpit-Bandejiya committed Jan 13, 2023
1 parent 20b72cc commit bcae783
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Removes Add Integration button ([#2723](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2723))
- Change geckodriver version to make consistency ([#2772](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2772))
- [Multi DataSource] Update default audit log path ([#2793](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2793))
- [Table Visualization] Fix first column sort issue ([#2828](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2828))

### 🚞 Infrastructure

Expand Down
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 bcae783

Please sign in to comment.