Didier Villevalois
12/19/2022, 11:02 AMStyle(...) in my root renderComposable() call, the results of re-compositions are appended to my "root" dom node instead of replacing the old content. If I remove the Style(...) call, then it works fine. Is this a regression ?
Tested with both (Kotlin 1.7.20 + Compose Multiplatform 1.2.2) and (Kotlin 1.7.21 + Compose Multiplatform 1.2.2 + Compose Compiler 1.4.0-alpha02).CLOVIS
12/19/2022, 2:04 PMStyle , and renderComposable has always prepended rather than erased.CLOVIS
12/19/2022, 2:04 PMDidier Villevalois
12/19/2022, 2:33 PMrenderComposable ?Didier Villevalois
12/19/2022, 2:37 PMStyle the content of the rootElementId is replaced at each composition. With the Style call, the content of the rootElementId is never reset and its html content only grows in size.CLOVIS
12/19/2022, 2:43 PMCLOVIS
12/19/2022, 2:43 PMOleksandr Karpovich [JB]
12/19/2022, 4:01 PMDidier Villevalois
12/19/2022, 5:07 PMimport androidx.compose.runtime.*
import org.jetbrains.compose.web.*
import org.jetbrains.compose.web.css.*
import org.jetbrains.compose.web.dom.*
fun startApp() {
renderComposable(rootElementId = "root") {
Style(AppStylesheet)
Test()
}
}
@Composable
fun Test() {
var counter by remember { mutableStateOf(0) }
if (counter % 2 == 0) {
P({ classes(AppStylesheet.counter) }) {
Text("$counter < Even")
}
} else {
P({ classes(AppStylesheet.counter) }) {
Text("$counter < Odd")
}
}
Button({ onClick { counter++ } }) {
Text("Increment")
}
}
object AppStylesheet : StyleSheet() {
val counter by style {
fontWeight("bold")
}
}
It seems the problem comes from the interaction between Style and the if statement.
Works without the Style call. Fails with the Style call.
Tested with Kotlin 1.7.21 + Compose Multiplatform 1.2.2 + Compose Compiler 1.4.0-alpha02.
@Oleksandr Karpovich [JB] Is this sufficient to open an issue?Oleksandr Karpovich [JB]
12/19/2022, 5:13 PMDidier Villevalois
12/19/2022, 5:16 PMOleksandr Karpovich [JB]
12/19/2022, 5:36 PMDidier Villevalois
12/19/2022, 5:40 PMOleksandr Karpovich [JB]
12/19/2022, 5:48 PMDidier Villevalois
12/19/2022, 5:59 PM