Merge remote-tracking branch 'origin/fix/106-wip' into HEAD

This commit is contained in:
claudiulodro 2018-09-06 11:48:37 -07:00
commit cb2e63f130
2 changed files with 15 additions and 7 deletions

View File

@ -1710,7 +1710,8 @@ var ProductSpecificSearchResults = function (_React$Component3) {
_this3.state = {
products: [],
query: ''
query: '',
loaded: false
};
_this3.updateResults = _this3.updateResults.bind(_this3);
@ -1768,7 +1769,8 @@ var ProductSpecificSearchResults = function (_React$Component3) {
var query = this.getQuery();
self.setState({
query: query
query: query,
loaded: false
});
if (query.length) {
@ -1776,13 +1778,15 @@ var ProductSpecificSearchResults = function (_React$Component3) {
// Only update the results if they are for the latest query.
if (query === self.getQuery()) {
self.setState({
products: products
products: products,
loaded: true
});
}
});
} else {
self.setState({
products: []
products: [],
loaded: true
});
}
}
@ -1794,7 +1798,7 @@ var ProductSpecificSearchResults = function (_React$Component3) {
}, {
key: 'render',
value: function render() {
if (!this.getQuery().length) {
if (!this.state.loaded || !this.state.query.length) {
return null;
}

View File

@ -185,6 +185,7 @@ class ProductSpecificSearchResults extends React.Component {
this.state = {
products: [],
query: '',
loaded: false
};
this.updateResults = this.updateResults.bind( this );
@ -228,7 +229,8 @@ class ProductSpecificSearchResults extends React.Component {
const query = this.getQuery();
self.setState( {
query: query
query: query,
loaded: false
} );
if ( query.length ) {
@ -237,12 +239,14 @@ class ProductSpecificSearchResults extends React.Component {
if ( query === self.getQuery() ) {
self.setState( {
products: products,
loaded: true
} );
}
} );
} else {
self.setState( {
products: [],
loaded: true
} );
}
}
@ -251,7 +255,7 @@ class ProductSpecificSearchResults extends React.Component {
* Render.
*/
render() {
if ( ! this.getQuery().length ) {
if ( ! this.state.loaded || ! this.state.query.length ) {
return null;
}