diff --git a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt index 9e9d26b49a129fee80f7544863d565f480d28c81..e995e3e5a31705ddd8fac0ddf73dbed83955a04f 100644 --- a/app/src/main/java/foundation/e/apps/search/SearchFragment.kt +++ b/app/src/main/java/foundation/e/apps/search/SearchFragment.kt @@ -148,15 +148,18 @@ class SearchFragment : override fun onItemRangeInserted(positionStart: Int, itemCount: Int) { searchView?.run { /* - * Only scroll back to 0 position for a new search. - * - * If we are getting new results from livedata for the old search query, - * do not scroll to top as the user may be scrolling to see already - * populated results. - */ - if (lastSearch != query?.toString()) { + * Only scroll back to 0 position for a new search. + * + * If we are getting new results from livedata for the old search query, + * do not scroll to top as the user may be scrolling to see already + * populated results. + * + * Compare lastSearch with searchText to avoid falsely updating to + * current query text even before submitting the new search. + */ + if (lastSearch != searchText) { recyclerView?.scrollToPosition(0) - lastSearch = query.toString() + lastSearch = searchText } } }