Background
I am making a desktop compose application.
I had a LazyColumn
with Divider
separating items. LazyColumn
's width may not fit in window so I made the LazyColumn
horizontally scrollable by enclosing it inside a Box
with horizontalScroll()
modifier set.
Now LazyColumn
became horizontal scrollable as well. But strangely the Divider
's separating the items disappeared.
After digging into it for a while, I figured out that Divider
's became invisible only when placed inside a horizontally scrollable parent.
Minimal Reproduction
Here is a minimal reproduction of observed behavior where red Divider
is clearly invisible when horizontalScroll(rememberScrollState())
modifier is set in enclosing Box
.
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
Box(
Modifier.fillMaxSize()
.background(Color.Green)
.horizontalScroll(rememberScrollState())
) {
Divider(thickness = 10.dp, color = Color.Red)
}
}
}
As it can be seen that the red Divider
is invisible for above code.
Expected Output:
With verticalScroll()
or no scroll modifier at all works fine as expected.
fun main() = application {
Window(onCloseRequest = ::exitApplication) {
Box(
Modifier.fillMaxSize()
.background(Color.Green)
.verticalScroll(rememberScrollState())
) {
Divider(thickness = 10.dp, color = Color.Red)
}
}
}
Correct output as expected, the red Divider
is clearly visible for above code.
Version info
kotlin("jvm") version "1.5.21"
id("org.jetbrains.compose") version "1.0.0-alpha3"
I'd like to know if this is a bug? or is there a way to fix this.