Skip to content

Commit 7031986

Browse files
author
Kyle Kim
committed
Merge remote-tracking branch 'upstream/master'
2 parents 51fb0e0 + 1afd606 commit 7031986

4 files changed

Lines changed: 16 additions & 11 deletions

File tree

lib/CollapsibleFilter/CollapsibleFilter.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,14 @@ var CollapsibleFilter = function (_React$Component) {
9898
textMore = _props2.textMore,
9999
textLess = _props2.textLess;
100100

101-
// Filter by search
102101

102+
var sortedFilter = filters[type].filter(function (a) {
103+
return a._id;
104+
}).sort(function (a, b) {
105+
return a._id.localeCompare(b._id);
106+
});
107+
108+
// Filter by search
103109
var filteredItems = search.all ? items : items.filter(function (job) {
104110
return search.results.includes(job.permalink);
105111
}) || [];
@@ -109,11 +115,7 @@ var CollapsibleFilter = function (_React$Component) {
109115
{ className: 'wfui-filter-group' },
110116
_react2.default.createElement(_FilterItems2.default, {
111117
label: label,
112-
filterItems: filterItems || filters[type].filter(function (a) {
113-
return a._id;
114-
}).sort(function (a, b) {
115-
return a._id.localeCompare(b._id);
116-
}).map(function (item) {
118+
filterItems: filterItems || sortedFilter.map(function (item) {
117119
return { _id: item._id, key: item._key || item._id, count: item.count };
118120
}),
119121
type: type,

lib/FilteredList/List.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ var List = function (_React$Component) {
8888
}
8989
}, {
9090
key: 'componentDidUpdate',
91-
value: function componentDidUpdate() {
91+
value: function componentDidUpdate(prevProps) {
9292
var _props3 = this.props,
9393
onDisplay = _props3.onDisplay,
9494
onNumOfListChange = _props3.onNumOfListChange,
@@ -102,7 +102,7 @@ var List = function (_React$Component) {
102102
/* Only setState and invoke callbacks when the state is changed to avoid infinite loop */
103103

104104

105-
if (activeData.length !== this.state.numOfItems || startingArticle !== this.state.startingArticle || lastArticle !== this.state.lastArticle) {
105+
if (activeData.length !== this.state.numOfItems || startingArticle !== this.state.startingArticle || lastArticle !== this.state.lastArticle || prevProps.data.length !== data.length) {
106106
this.updateStatus();
107107
}
108108
}

src/CollapsibleFilter/CollapsibleFilter.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ class CollapsibleFilter extends React.Component {
4040
render() {
4141
const { label, type, filters, search, filterItems, items, category, filter, defaultExpand, numCollapse, textMore, textLess } = this.props;
4242

43+
const sortedFilter = filters[type].filter((a) => (a._id)).sort((a, b) => (a._id.localeCompare(b._id)));
44+
4345
// Filter by search
4446
const filteredItems = search.all ? items : items.filter(job => search.results.includes(job.permalink)) || [];
4547

4648
return (
4749
<div className="wfui-filter-group">
4850
<FilterItems
4951
label={label}
50-
filterItems={filterItems || filters[type].filter((a) => (a._id)).sort((a, b) => (a._id.localeCompare(b._id))).map(item => ({ _id: item._id, key: item._key || item._id, count: item.count }))}
52+
filterItems={filterItems || sortedFilter.map(item => ({ _id: item._id, key: item._key || item._id, count: item.count }))}
5153
type={type}
5254
category={category}
5355
onHandleClick={this.onHandleClick}

src/FilteredList/List.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,15 @@ class List extends React.Component {
5353
return populatedContainer;
5454
}
5555

56-
componentDidUpdate() {
56+
componentDidUpdate(prevProps) {
5757
const { onDisplay, onNumOfListChange, data } = this.props;
5858
const { activeData, startingArticle, lastArticle } = calcActiveData(this.props);
5959

6060
/* Only setState and invoke callbacks when the state is changed to avoid infinite loop */
6161
if ( activeData.length !== this.state.numOfItems ||
6262
startingArticle !== this.state.startingArticle ||
63-
lastArticle !== this.state.lastArticle) {
63+
lastArticle !== this.state.lastArticle ||
64+
prevProps.data.length !== data.length) {
6465
this.updateStatus();
6566
}
6667
}

0 commit comments

Comments
 (0)