Skip to content

Commit

Permalink
Fixed #617 - Datatable multisort broken
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 28, 2019
1 parent 8cdba01 commit c42543f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/datatable/DataTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ export class DataTable extends Component {

onSort(event) {
let sortField = event.sortField;
let sortOrder = (this.getSortField() === event.sortField) ? this.getSortOrder() * -1 : this.props.defaultSortOrder;
let sortOrder;
let multiSortMeta;

this.columnSortable = event.sortable;
Expand All @@ -458,12 +458,19 @@ export class DataTable extends Component {
if(this.props.sortMode === 'multiple') {
let metaKey = event.originalEvent.metaKey || event.originalEvent.ctrlKey;
multiSortMeta = this.getMultiSortMeta();

const sortMeta = multiSortMeta.find(sortMeta => sortMeta.field === sortField);
sortOrder = sortMeta ? sortMeta.order * -1 : this.props.defaultSortOrder;

if(!multiSortMeta || !metaKey) {
multiSortMeta = [];
}

this.addSortMeta({field: sortField, order: sortOrder}, multiSortMeta);
}
else {
sortOrder = (this.getSortField() === sortField) ? this.getSortOrder() * -1 : this.props.defaultSortOrder;
}

if (this.props.onSort) {
this.props.onSort({
Expand Down

0 comments on commit c42543f

Please sign in to comment.