From 8a7dabfaddbd83e1c1bd2e3e0333e03d15477bd6 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Wed, 14 Nov 2018 10:51:29 -0300 Subject: [PATCH] Fix regression when scrolling in search screen (#2339) --- app/screens/search/search.js | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/app/screens/search/search.js b/app/screens/search/search.js index a7099f575ba..01bfecd6ec6 100644 --- a/app/screens/search/search.js +++ b/app/screens/search/search.js @@ -121,9 +121,10 @@ export default class Search extends PureComponent { componentDidUpdate(prevProps) { const {searchingStatus: status, recent, enableDateSuggestion} = this.props; - const shouldScroll = status === RequestStatus.SUCCESS && - !this.props.isSearchGettingMore && - !prevProps.isSearchGettingMore; + const {searchingStatus: prevStatus} = prevProps; + const shouldScroll = prevStatus !== status && + (status === RequestStatus.SUCCESS || status === RequestStatus.STARTED) && + !this.props.isSearchGettingMore && !prevProps.isSearchGettingMore; if (this.props.isLandscape !== prevProps.isLandscape) { this.refs.searchBar.blur(); @@ -702,17 +703,21 @@ export default class Search extends PureComponent { } break; case RequestStatus.FAILURE: - results = [{ - id: RequestStatus.FAILURE, - component: ( - - - - ), - }]; + if (postIds.length) { + results = postIds; + } else { + results = [{ + id: RequestStatus.FAILURE, + component: ( + + + + ), + }]; + } break; }