Here's a very weird bug. Having the below code in ...
# compose
d
Here's a very weird bug. Having the below code in a Card that has a Border (a normal, solid, 1dp non-conditional border) causes the Card's Border to use a horizontal gradient color (and a radial if i change the below to use radial). The super bizarre thing is that it swaps between using the gradient and showing the expected solid line when I move my mouse around, like a flicker, without any modifiers set up that do things based on mouse movement.
Copy code
Box(
                    modifier = Modifier
                        .background(
                            brush = Brush.horizontalGradient(
                                colors = listOf(
                                    MaterialTheme.colors.primary.lighten(50).copy(alpha = 0.35f),
                                    Color.Transparent
                                ),
                            )
                        )
                        .size(32.dp)
                )
                {}
ah, it's switching to the solid line when a tooltip pops up...hmmm
Card code
Copy code
Card(
            modifier = Modifier
                .wrapContentHeight()
                .border(
                    shape = SmolTheme.smolFullyClippedButtonShape(),
                    border = if (isActiveProfile)
                    // Highlight active profile
                        BorderStroke(
                            width = 4.dp,
                            color = MaterialTheme.colors.onSurface.lighten()
                        )
                    else
                        BorderStroke(
                            width = 1.dp,
                            color = MaterialTheme.colors.surface.lighten()
                        )
                )
Both the border and gradient use
MaterialTheme.colors.onSurface
, and the gradient uses
Copy code
val alphaOfHoverDimmedElements = animateFloatAsState(if (isBeingHovered) 0.8f else 0.5f).value
but I'm using
MaterialTheme.colors.onSurface.copy(alpha = alphaOfHoverDimmedElements)
so it shouldn't affect the color anywhere else...
solved it by adding a
Copy code
.clipToBounds()
to the Modifier to my gradient-containing Box
very very strange behavior
having the border of a parent of an element be affected by the child's background brush being a gradient
z
Is this on android or desktop?
d
Desktop
I tried to come up with a minimum reproducible setup but it was, well, weird
"chaos bug" is the phrase
like, if I put the gradient code above a specific Text, the bug would happen, but if I moved it below, it wouldn't
and it was just a regular Text, nothing odd in there, and both in the same layout
I kept expecting to find The Dumb Thing that I was doing, like accidentally mutating shared state, but never did, and then the fix being to add
.clipToBounds()
more or less confirmed (in my mind) that it's something within Compose
unfortunately, my code isn't open source yet - hopefully within the next month it will be, though
z
You probably want to post in #compose-desktop then
d
oh, I thought that was for things specific to desktop only
is this channel Android-specific?
z
If it's a rendering issue on desktop, then it's probably desktop specific
d
I see the channel description is for "Jetpack Compose", which is specific to Android...my bad, didn't catch that.
hm, I hadn't made that logical leap and thought it might happen on Android as well, as none of the actual code involved was android-specific.
anyway, message understood 🙂 thank you
z
If you can repro on android as well that would be even better for troubleshooting. But if you're only seeing it on desktop then I'd ask in the desktop channel
👍 1