Skip to content
This repository has been archived by the owner on Dec 13, 2020. It is now read-only.

Commit

Permalink
Changes after review #1590
Browse files Browse the repository at this point in the history
(cherry picked from commit 316fa1e)
  • Loading branch information
siemiatj authored and metas-ts committed Feb 16, 2018
1 parent 42f2c98 commit 267aca4
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/components/table/TableHeader.js
Expand Up @@ -30,15 +30,25 @@ class TableHeader extends Component {
if (!sortable) {
return;
}

const { sort, deselect, page, tabid } = this.props;
const fieldsCopy = { ...this.state.fields };
const sortingValue = fieldsCopy[field];

fieldsCopy[field] = !sortingValue;
const stateFields = this.state.fields;
let fields = {};
let sortingValue = null;

if (field in stateFields) {
fields = { ...stateFields };
sortingValue = !fields[field];
fields[field] = sortingValue;
} else {
sortingValue = !Object.values(stateFields).reduce(
(acc, curr) => acc && curr,
true
);
fields[field] = sortingValue;
}

this.setState({
fields: { ...fieldsCopy },
fields: { ...fields },
});

sort(sortingValue, field, true, page, tabid);
Expand Down

0 comments on commit 267aca4

Please sign in to comment.