compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

compose-web: TextArea does not show newlines

Open simonsample opened this issue 3 years ago • 2 comments

Hi! When I load a string into a TextArea, the newline characters are ignored. The other way (retrieving the value from the TextArea after a user-input with newlines was done) works as expected. Can someone confirm this problem? Did I do something wrong, or is there another way / a workaround to somehow set a multiline string in a TextArea?

simonsample avatar Jul 04 '22 09:07 simonsample

I just noticed, that newlines appear when setting the text with TextArea { value(s) } but I do not know how to allow user input here, so instead I use TextArea { defaultValue(s) } and this is where the problem with the ignored newlines appears.

simonsample avatar Jul 04 '22 11:07 simonsample

val inputState = remember { mutableStateOf("Some Text") }

TextArea {
    value(inputState.value)
    onInput { event -> println(event.value) }
}

This is how TextArea can take user's input. (https://github.com/JetBrains/compose-jb/blob/master/tutorials/Web/Controlled_Uncontrolled_Inputs/README.md)

eymar avatar Jul 11 '22 11:07 eymar