Skip to content

Commit 659d508

Browse files
wellorbetterStageGuard
authored andcommitted
fix(search): use editingQuery instead of presentationFlow in startSea… (#2942)
fix(search): use editingQuery instead of presentationFlow in startSearch fixes #2914 presentationFlow is collected asynchronously from queryFlow. When a history item is clicked, setQuery() and startSearch() run synchronously on the main thread with no coroutine dispatch in between, so presentationFlow.value is always stale at the time startSearch() reads it. This causes startSearch to pass an empty string to SearchPageState.startSearch(), which then overwrites queryFlow back to empty and calls searchState.clear(), making results disappear. editingQuery is a synchronous mutableStateOf written by setQuery(), so it always reflects the correct value at call time.
1 parent 0497dc3 commit 659d508

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

app/shared/ui-exploration/src/commonMain/kotlin/ui/exploration/search/SuggestionSearchBarState.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ class SuggestionSearchBarState(
104104
}
105105

106106
fun startSearch() {
107-
val rawQuery = presentationFlow.value.query
107+
val rawQuery = editingQuery
108108
val query = rawQuery.trim()
109109
val tags = tagsProvider()
110110
if (query != rawQuery) {

0 commit comments

Comments
 (0)