Skip to content

Commit 35fe072

Browse files
committed
Prevent to hide ime when editor delete newline
1 parent 829d507 commit 35fe072

File tree

1 file changed

+8
-2
lines changed
  • texteditor/src/main/java/jp/kaleidot725/texteditor/view

1 file changed

+8
-2
lines changed

texteditor/src/main/java/jp/kaleidot725/texteditor/view/TextEditor.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import androidx.compose.runtime.getValue
88
import androidx.compose.runtime.mutableStateOf
99
import androidx.compose.runtime.remember
1010
import androidx.compose.ui.Modifier
11+
import androidx.compose.ui.focus.FocusDirection
1112
import androidx.compose.ui.focus.FocusRequester
13+
import androidx.compose.ui.platform.LocalFocusManager
1214
import jp.kaleidot725.texteditor.state.EditableTextEditorState
1315
import jp.kaleidot725.texteditor.state.TextEditorState
1416

@@ -23,6 +25,8 @@ fun TextEditor(
2325
items = textEditorState.toEditable().fields,
2426
key = { _, item -> item.id }
2527
) { index, textFieldState ->
28+
// workaround: prevent to hide ime when editor delete newline
29+
val focusManager = LocalFocusManager.current
2630
val focusRequester by remember { mutableStateOf(FocusRequester()) }
2731

2832
LaunchedEffect(textFieldState.isSelected) {
@@ -44,14 +48,16 @@ fun TextEditor(
4448
onDeleteNewLine = {
4549
textEditorState.toEditable().deleteField(targetIndex = index)
4650
onUpdatedState()
51+
52+
// workaround: prevent to hide ime when editor delete newline
53+
focusManager.moveFocus(FocusDirection.Up)
4754
},
4855
focusRequester = focusRequester,
4956
onFocus = {
5057
if (textEditorState.selectedIndices.contains(index)) return@TextField
5158
textEditorState.toEditable().selectField(targetIndex = index)
5259
onUpdatedState()
53-
},
54-
modifier = modifier
60+
}
5561
)
5662
}
5763
}

0 commit comments

Comments
 (0)