Serhii K
07/29/2026, 10:05 AMSerhii K
07/29/2026, 10:06 AM@Composable
fun CommentContentLayout(
state: TextFieldState,
onTextEntered: (String) -> Unit,
) {
OutlinedTextField(
state = state,
modifier = Modifier.fillMaxWidth(),
readOnly = false,
lineLimits = TextFieldLineLimits.MultiLine(3),
)
LaunchedEffect(state) {
snapshotFlow { state.text.toString() }
.collectLatest { newText ->
onTextEntered(newText)
}
}
}
The state is created like this:
kotlin
val state = rememberTextFieldState()
For edit mode, it is initialized with existing content:
kotlin
val state = rememberTextFieldState(initialText)
```Serhii K
07/29/2026, 10:07 AMOutlinedTextField
- State-based API: TextFieldState
- Multiline field
- Only reported on Samsung devices / Samsung Keyboard
- Crash appears related to IME batch edit / delete operation
- Example crash has length=56; index=56, so it is not limited to very long textSerhii K
07/29/2026, 10:08 AMForm Crash report:
Fatal Exception: java.lang.StringIndexOutOfBoundsException: length=56; index=56
at java.lang.String.charAt(String.java)
at androidx.compose.foundation.text.input.internal.ToCharArray_androidKt.toCharArray(ToCharArray.android.kt:32)
at androidx.compose.foundation.text.input.internal.PartialGapBuffer.replace(GapBuffer.kt:246)
at androidx.compose.foundation.text.input.internal.PartialGapBuffer.replace(GapBuffer.kt:280)
at androidx.compose.foundation.text.input.TextFieldBuffer.replace$foundation(TextFieldBuffer.kt:313)
at androidx.compose.foundation.text.input.TextFieldBuffer.replace(TextFieldBuffer.kt:285)
at androidx.compose.foundation.text.input.TextFieldBufferKt.delete(TextFieldBuffer.kt:646)
at androidx.compose.foundation.text.input.internal.ImeEditCommand_androidKt.imeDelete(ImeEditCommand.android.kt:473)
at androidx.compose.foundation.text.input.internal.ImeEditCommand_androidKt.deleteSurroundingText$lambda$0(ImeEditCommand.android.kt:301)
at androidx.compose.foundation.text.input.internal.DefaultImeEditCommandScope.endBatchEdit(ImeEditCommand.android.kt:132)
at androidx.compose.foundation.text.input.internal.StatelessInputConnection.endBatchEdit(StatelessInputConnection.android.kt:218)Halil Ozercan
07/29/2026, 9:07 PMHalil Ozercan
07/29/2026, 9:08 PMSerhii K
07/30/2026, 7:49 AM