https://kotlinlang.org logo
#compose-android
Title
# compose-android
t

Toan Nguyen

09/28/2023, 8:26 AM
Hi guys, i'm trying singleLine for Textfield. When i paste text has \n to TextField
singleLine = true
it not working(Example in photo). In Android Native, it will auto replace
\n
to
space
when i set singleLine = true for EditText. So i wanna ask TextField in compose has something like that?
b

Blundell

09/28/2023, 8:56 AM
How do you know that the LogCat out represents the way its drawn in Compose? It might keep the newline for the callback but when rendering ignore it 🙂
t

Toan Nguyen

09/28/2023, 8:59 AM
@Blundell the view also render like LogCat, text \n below textField and i still interact with it
b

Blundell

09/28/2023, 9:01 AM
ah so the screenshot is your view? not logcat
t

Toan Nguyen

09/28/2023, 9:04 AM
@Blundell u can see this bug in video below
b

Blundell

09/28/2023, 10:00 AM
I see, so when you paste a new line it renders a new line, you control the text, why not do
text = text.replace("\n", " ")
t

Toan Nguyen

09/28/2023, 10:02 AM
@Blundell i have solution already but i want to ask whether TextField has any property do same EditText in android native just Textfield.something() 😂
In the current BasicTextField I don’t think we handle it at all
❤️ 1