Skip to content
This repository was archived by the owner on May 4, 2019. It is now read-only.

Commit a1b2a6b

Browse files
author
Evan Horne
committed
fix(itemtablecontainer): grid sorts individually
1 parent 93d5603 commit a1b2a6b

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

package-lock.json

+7-21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@
137137
},
138138
"peerDependencies": {
139139
"react": "^15.0.0 || ^16",
140-
"react-dom": "^15.0.0 || ^16",
140+
"react-dom": "^15.0.0 || ^16.4.0",
141141
"bootstrap": "^3.3.7 || ^4",
142142
"jquery": "^3.2.1",
143143
"font-awesome": "~4.7.0",

src/ItemTable/ItemTableContainer.tsx

+15
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,23 @@ export class ItemTableContainer extends React.Component<
5959
* @param {ColumnGroup} col
6060
*/
6161
onClickHeader = (col: ColumnGroup) => {
62+
const sortCheck = (this.state.sorts || []).slice();
63+
const unmatchFound = sortCheck.findIndex(
64+
hs => hs.col.header !== col.header
65+
);
66+
const newSortModel: HeaderSortModel = {
67+
col,
68+
direction: SortDirection.NoSort,
69+
resetSortCount: 0
70+
};
71+
if (unmatchFound > -1) {
72+
this.state = {
73+
sorts: [newSortModel]
74+
};
75+
}
6276
const newSorts = (this.state.sorts || []).slice();
6377
const headIdx = newSorts.findIndex(hs => hs.col.header === col.header);
78+
6479
if (headIdx !== -1) {
6580
const newSort = { ...newSorts[headIdx] };
6681
if (newSort.direction === SortDirection.Ascending) {

0 commit comments

Comments
 (0)