don't default sort by to first column (#2653)

This commit is contained in:
Alanna Scott 2017-04-20 12:34:35 -07:00 committed by GitHub
parent 938e13a429
commit 84fa0d1940

View File

@ -41,7 +41,7 @@ export default class FilterableTable extends PureComponent {
.reduce((curr, next) => curr + next); .reduce((curr, next) => curr + next);
this.state = { this.state = {
sortBy: props.orderedColumnKeys[0], sortBy: null,
sortDirection: SortDirection.ASC, sortDirection: SortDirection.ASC,
fitted: false, fitted: false,
}; };
@ -142,9 +142,11 @@ export default class FilterableTable extends PureComponent {
sortedAndFilteredList = this.list.filter(row => this.hasMatch(filterText, row)); sortedAndFilteredList = this.list.filter(row => this.hasMatch(filterText, row));
} }
// sort list // sort list
sortedAndFilteredList = sortedAndFilteredList if (sortBy) {
sortedAndFilteredList = sortedAndFilteredList
.sortBy(item => item[sortBy]) .sortBy(item => item[sortBy])
.update(list => sortDirection === SortDirection.DESC ? list.reverse() : list); .update(list => sortDirection === SortDirection.DESC ? list.reverse() : list);
}
const rowGetter = ({ index }) => this.getDatum(sortedAndFilteredList, index); const rowGetter = ({ index }) => this.getDatum(sortedAndFilteredList, index);