diff --git a/src/webui/components/Search/index.js b/src/webui/components/Search/index.js index 5874723de..1cc0f151f 100644 --- a/src/webui/components/Search/index.js +++ b/src/webui/components/Search/index.js @@ -98,7 +98,7 @@ class Search extends Component { case 'click': case 'enter': this.setState({ search: '' }); - window.location.href = getDetailPageURL(suggestionValue); + window.location.assign(getDetailPageURL(suggestionValue)); break; } }; @@ -114,23 +114,22 @@ class Search extends Component { // Keep track of search requests. this.requestList.push(controller); const response = await API.request(`search/${encodeURIComponent(value)}`, 'GET', { signal }); - this.setState({ loaded: true }); const transformedPackages = response.map(({ name, ...others }) => ({ label: name, ...others, })); - if (this.state.search === value) { - this.setState({ - suggestions: transformedPackages, - loaded: true, - }); - } + this.setState({ + suggestions: transformedPackages, + loaded: true, + }); } catch (error) { /** * AbortError is not the API error. * It means browser has cancelled the API request. */ - if (error.name !== CONSTANTS.ABORT_ERROR) { + if (error.name === CONSTANTS.ABORT_ERROR) { + this.setState({ error: false, loaded: false }); + } else { this.setState({ error: true, loaded: false }); } } finally { diff --git a/test/unit/webui/components/__snapshots__/footer.spec.js.snap b/test/unit/webui/components/__snapshots__/footer.spec.js.snap index b976842a4..8162e4f4b 100644 --- a/test/unit/webui/components/__snapshots__/footer.spec.js.snap +++ b/test/unit/webui/components/__snapshots__/footer.spec.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`