Skip to content

Commit

Permalink
Fix WheelPicker Manual Input (#1209)
Browse files Browse the repository at this point in the history
* Fix WheelPicker Manual Input

* Lambda

* inline

* Update WheelPicker.kt

---------

Co-authored-by: AntsyLich <[email protected]>
(cherry picked from commit 339dc33)
  • Loading branch information
Animeboynz authored and cuong-tran committed Sep 15, 2024
1 parent ba43e55 commit 461e239
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ private fun <T> WheelPicker(
}

val scope = rememberCoroutineScope()
fun onDone() {
val processManualInput: () -> Unit = {
scope.launch {
items
.indexOfFirst { it.toString() == value.text }
Expand All @@ -158,7 +158,6 @@ private fun <T> WheelPicker(
internalOnSelectionChanged(this)
lazyListState.scrollToItem(this)
}

showManualInput = false
}
}
Expand All @@ -167,10 +166,10 @@ private fun <T> WheelPicker(
.align(Alignment.Center)
.showSoftKeyboard(true)
// KMK -->
.clearFocusOnSoftKeyboardHide { onDone() },
.clearFocusOnSoftKeyboardHide(processManualInput),
/* clearFocusOnSoftKeyboardHide doesn't work because onSoftKeyboardHide won't trigger
a recomposition => use keyboardActions instead */
onKeyboardAction = { onDone() },
onKeyboardAction = { processManualInput() },
// KMK <--
state = value,
lineLimits = TextFieldLineLimits.SingleLine,
Expand Down

0 comments on commit 461e239

Please sign in to comment.