https://kotlinlang.org logo
#compose-web
Title
# compose-web
c

Chris Sinco [G]

09/07/2023, 2:18 AM
There seems to be a runtime crash with Compose WASM with
TextField
in Material2 (haven't tested Material3) in 1.4.1, on recomposition when changing themes and used in a
Surface
. Code snippet below should repro the crash in browser:
Copy code
var useDarkTheme by remember { mutableStateOf(false) }
var text by remember { mutableStateOf("Hello") }

MaterialTheme(
    colors = if (useDarkTheme) darkColors() else lightColors()
) {
    Surface {
        TextField(
            value = text,
            onValueChange = { text = it },
            label = { Text("Label") }
        )
        Button(onClick = { useDarkTheme = !useDarkTheme }) {
            Text("Toggle theme")
        }
    }
}
It works fine if you don't change colors on the fly, which is odd. Also this happens with
BasicTextField
so it's likely a deeper issue than the Material layer. Is this a known issue?
This is the crash I see in Chrome
m

Mitchell Syer

09/07/2023, 3:13 AM
I believe
toLanguageTag
was implemented in Compose 1.5, before that it threw the not implemented exception
o

Oleksandr Karpovich [JB]

09/07/2023, 2:20 PM
Compose for Web 1.5.0 with k/wasm is not yet published, but WIP. toLanguageTag should be implemented there
👍 1
7 Views