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
MrPowerGamerBR
08/02/2021, 4:33 PM
(This bug is also present in 1.0.0-alpha1-rc2)
o
Oleksandr Karpovich [JB]
08/02/2021, 4:36 PM
it's indeed something we haven't seen yet. thanks for reporting! I'll have a look
Oleksandr Karpovich [JB]
08/02/2021, 4:44 PM
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
MrPowerGamerBR
08/02/2021, 6:00 PM
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 😛