From edb8fb0b282804e6dd3e9adbc808bce810a6bb24 Mon Sep 17 00:00:00 2001 From: Nebojsa Vuksic Date: Fri, 1 Aug 2025 12:53:39 +0200 Subject: [PATCH] Properly notify parents when SearchBarWithAutoCompletion text field text is cleared --- .../template/components/SearchBarWithAutoCompletion.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/org/jetbrains/plugins/template/components/SearchBarWithAutoCompletion.kt b/src/main/kotlin/org/jetbrains/plugins/template/components/SearchBarWithAutoCompletion.kt index 2347deb..6a52110 100644 --- a/src/main/kotlin/org/jetbrains/plugins/template/components/SearchBarWithAutoCompletion.kt +++ b/src/main/kotlin/org/jetbrains/plugins/template/components/SearchBarWithAutoCompletion.kt @@ -58,6 +58,10 @@ internal fun SearchBarWithAutoCompletion( snapshotFlow { textFieldState.text.toString() } .distinctUntilChanged() .collect { searchTerm -> + if (searchTerm.isEmpty()) { + onClear() + } + popupController.onQueryChanged(searchTerm) } } @@ -81,7 +85,6 @@ internal fun SearchBarWithAutoCompletion( trailingIcon = { if (!isInputFieldEmpty) { CloseIconButton { - onClear() textFieldState.setTextAndPlaceCursorAtEnd("") } }