Properly notify parents when SearchBarWithAutoCompletion text field text is cleared

This commit is contained in:
Nebojsa Vuksic 2025-08-01 12:53:39 +02:00
parent cb6c908769
commit edb8fb0b28

View File

@ -58,6 +58,10 @@ internal fun <T> SearchBarWithAutoCompletion(
snapshotFlow { textFieldState.text.toString() } snapshotFlow { textFieldState.text.toString() }
.distinctUntilChanged() .distinctUntilChanged()
.collect { searchTerm -> .collect { searchTerm ->
if (searchTerm.isEmpty()) {
onClear()
}
popupController.onQueryChanged(searchTerm) popupController.onQueryChanged(searchTerm)
} }
} }
@ -81,7 +85,6 @@ internal fun <T> SearchBarWithAutoCompletion(
trailingIcon = { trailingIcon = {
if (!isInputFieldEmpty) { if (!isInputFieldEmpty) {
CloseIconButton { CloseIconButton {
onClear()
textFieldState.setTextAndPlaceCursorAtEnd("") textFieldState.setTextAndPlaceCursorAtEnd("")
} }
} }