Skip to content

Commit b7f81da

Browse files
committed
fix the text field search bar was not focused when it appears
1 parent 03a6b0a commit b7f81da

File tree

1 file changed

+6
-1
lines changed
  • src/jvmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/ux

1 file changed

+6
-1
lines changed

src/jvmMain/kotlin/com/sunnychung/application/multiplatform/hellohttp/ux/CodeEditorView.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,14 +682,19 @@ fun TextSearchBar(
682682
) {
683683
val textSizes = LocalFont.current
684684
Row(modifier = modifier.padding(bottom = 2.dp), verticalAlignment = Alignment.CenterVertically) {
685+
val focusRequester = remember { FocusRequester() }
685686
AppTextField(
686687
key = "$key/SearchText",
687688
value = text,
688689
onValueChange = onTextChange,
689690
textStyle = LocalTextStyle.current.copy(fontSize = textSizes.searchInputSize),
690691
maxLines = 1,
691-
modifier = Modifier.weight(1f),
692692
singleLine = true, // TODO allow '\n'
693+
onFinishInit = {
694+
focusRequester.requestFocus()
695+
},
696+
modifier = Modifier.weight(1f)
697+
.focusRequester(focusRequester),
693698
)
694699
AppText(text = statusText, fontSize = textSizes.supplementSize, modifier = Modifier.padding(horizontal = 4.dp))
695700
AppTextToggleButton(

0 commit comments

Comments
 (0)