From 339dc33f5833b224c01577da3da081deecdbbca2 Mon Sep 17 00:00:00 2001 From: Roshan Varughese <40583749+Animeboynz@users.noreply.github.com> Date: Sun, 15 Sep 2024 02:43:03 +1200 Subject: [PATCH] Fix WheelPicker Manual Input (#1209) * Fix WheelPicker Manual Input * Lambda * inline * Update WheelPicker.kt --------- Co-authored-by: AntsyLich <59261191+AntsyLich@users.noreply.github.com> --- .../core/components/WheelPicker.kt | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/presentation-core/src/main/java/tachiyomi/presentation/core/components/WheelPicker.kt b/presentation-core/src/main/java/tachiyomi/presentation/core/components/WheelPicker.kt index c4cf6e471..8187dd4ce 100644 --- a/presentation-core/src/main/java/tachiyomi/presentation/core/components/WheelPicker.kt +++ b/presentation-core/src/main/java/tachiyomi/presentation/core/components/WheelPicker.kt @@ -149,23 +149,25 @@ private fun WheelPicker( } val scope = rememberCoroutineScope() + val processManualInput: () -> Unit = { + scope.launch { + items + .indexOfFirst { it.toString() == value.text } + .takeIf { it >= 0 } + ?.apply { + internalOnSelectionChanged(this) + lazyListState.scrollToItem(this) + } + showManualInput = false + } + } + BasicTextField( modifier = Modifier .align(Alignment.Center) .showSoftKeyboard(true) - .clearFocusOnSoftKeyboardHide { - scope.launch { - items - .indexOfFirst { it.toString() == value.text } - .takeIf { it >= 0 } - ?.apply { - internalOnSelectionChanged(this) - lazyListState.scrollToItem(this) - } - - showManualInput = false - } - }, + .clearFocusOnSoftKeyboardHide(processManualInput), + onKeyboardAction = { processManualInput() }, state = value, lineLimits = TextFieldLineLimits.SingleLine, keyboardOptions = KeyboardOptions(