@@ -8,7 +8,9 @@ import androidx.compose.runtime.getValue
8
8
import androidx.compose.runtime.mutableStateOf
9
9
import androidx.compose.runtime.remember
10
10
import androidx.compose.ui.Modifier
11
+ import androidx.compose.ui.focus.FocusDirection
11
12
import androidx.compose.ui.focus.FocusRequester
13
+ import androidx.compose.ui.platform.LocalFocusManager
12
14
import jp.kaleidot725.texteditor.state.EditableTextEditorState
13
15
import jp.kaleidot725.texteditor.state.TextEditorState
14
16
@@ -23,6 +25,8 @@ fun TextEditor(
23
25
items = textEditorState.toEditable().fields,
24
26
key = { _, item -> item.id }
25
27
) { index, textFieldState ->
28
+ // workaround: prevent to hide ime when editor delete newline
29
+ val focusManager = LocalFocusManager .current
26
30
val focusRequester by remember { mutableStateOf(FocusRequester ()) }
27
31
28
32
LaunchedEffect (textFieldState.isSelected) {
@@ -44,14 +48,16 @@ fun TextEditor(
44
48
onDeleteNewLine = {
45
49
textEditorState.toEditable().deleteField(targetIndex = index)
46
50
onUpdatedState()
51
+
52
+ // workaround: prevent to hide ime when editor delete newline
53
+ focusManager.moveFocus(FocusDirection .Up )
47
54
},
48
55
focusRequester = focusRequester,
49
56
onFocus = {
50
57
if (textEditorState.selectedIndices.contains(index)) return @TextField
51
58
textEditorState.toEditable().selectField(targetIndex = index)
52
59
onUpdatedState()
53
- },
54
- modifier = modifier
60
+ }
55
61
)
56
62
}
57
63
}
0 commit comments