From a6b9e036223aeeb47a5337f49fce533117b9f23f Mon Sep 17 00:00:00 2001 From: Ethan Alvizo Date: Wed, 5 Jul 2023 15:00:41 -0400 Subject: [PATCH] PR feedback --- .../src/AdvancedFilterCreator.test.tsx | 2 +- .../iris-grid/src/AdvancedFilterCreator.tsx | 6 +----- packages/iris-grid/src/IrisGrid.tsx | 17 +++++++++-------- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/packages/iris-grid/src/AdvancedFilterCreator.test.tsx b/packages/iris-grid/src/AdvancedFilterCreator.test.tsx index 8bf2dbf6ac..0b5f21004e 100644 --- a/packages/iris-grid/src/AdvancedFilterCreator.test.tsx +++ b/packages/iris-grid/src/AdvancedFilterCreator.test.tsx @@ -54,7 +54,7 @@ function makeAdvancedFilterCreatorWrapper( selectedValues: [], }, model: irisGridTestUtils.makeModel(), - column: irisGridTestUtils.makeColumn(), + column: irisGridTestUtils.makeColumn('0'), // needs to match column name in makeModel so that columnIndex can be found when rendering formatter: new Formatter(dh), } ) { diff --git a/packages/iris-grid/src/AdvancedFilterCreator.tsx b/packages/iris-grid/src/AdvancedFilterCreator.tsx index 2097651060..850f2fbb7e 100644 --- a/packages/iris-grid/src/AdvancedFilterCreator.tsx +++ b/packages/iris-grid/src/AdvancedFilterCreator.tsx @@ -214,11 +214,7 @@ class AdvancedFilterCreator extends PureComponent< ); this.valuesTablePromise .then(valuesTable => { - const columnIndex = model.getColumnIndexByName( - valuesTable.columns[0].name - ); - assertNotNull(columnIndex); - if (model.isColumnSortable(columnIndex)) { + if (valuesTable.columns[0].isSortable ?? true) { const sort = valuesTable.columns[0].sort().asc(); valuesTable.applySort([sort]); } diff --git a/packages/iris-grid/src/IrisGrid.tsx b/packages/iris-grid/src/IrisGrid.tsx index 40b1a81c1d..ce6316b096 100644 --- a/packages/iris-grid/src/IrisGrid.tsx +++ b/packages/iris-grid/src/IrisGrid.tsx @@ -2401,16 +2401,17 @@ export class IrisGrid extends Component { log.info('Toggling sort for column', columnIndex); const { model } = this.props; - const { sorts: currentSorts } = this.state; const modelColumn = this.getModelColumn(columnIndex); assertNotNull(modelColumn); - const sorts = TableUtils.toggleSortForColumn( - currentSorts, - model.columns, - modelColumn, - addToExisting - ); - if (model.columns[columnIndex].isSortable ?? false) { + if (model.isColumnSortable(columnIndex)) { + const { sorts: currentSorts } = this.state; + const sorts = TableUtils.toggleSortForColumn( + currentSorts, + model.columns, + modelColumn, + addToExisting + ); + this.updateSorts(sorts); } else { log.debug('Column type was not sortable', model.columns[columnIndex]);