First, yet another bug that I've found that I didn...
# compose-web
m
First, yet another bug that I've found that I didn't seem to find someone else reporting this:
Copy code
var disableButton by remember { mutableStateOf(false) }

                Button(attrs = {
                    style {
                        width(100.percent)
                    }

                    if (disableButton)
                        disabled()
                }) {
                    Text("This is a button")
                }

                Button(attrs = {
                    onClick {
                        disableButton = !disableButton
                    }
                }) {
                    Text("Toggle button")
                }
Clicking the second button disables the first button... but it also removes the style (the width: 100%) of the first button!
😥 1
(This bug is also present in 1.0.0-alpha1-rc2)
o
it's indeed something we haven't seen yet. thanks for reporting! I'll have a look
it's a bug indeed. But if you want, you can use Stylesheet:
Copy code
object MyStylesheet : StyleSheet() {

    val buttonClass by style {
        width(100.percent)
    }
}

fun main() {
    renderComposableInBody {
        var disableButton by remember { mutableStateOf(false) }
        Style(MyStylesheet)

        Button(attrs = {
           classes(MyStylesheet.buttonClass)
            
           if (disableButton)
                disabled()

        }) {
            Text("This is a button")
        }
        Button(attrs = {
            onClick {
                disableButton = !disableButton
            }
        }) {
            Text("Toggle button")
        }
    }
}
🙏 1
m
Thank you! I do have a stylesheet made with SASS, but I was too lazy to add the width: 100% there, so I tried adding it in Compose for now... and that's how I found out about the issue 😛
👍 1
o