I've got a layout of `[fixed size text] [any lengt...
# compose
m
I've got a layout of
[fixed size text] [any length text] [icon button]
, how can I make it so only the middle text can wrap lines if it doesn't fit? Default behavior seems to be to first shrink the icon button until no longer visible, and only then line-wrap the text.
m
I saw that and tried it, but instead the icon still shrinks before the text starts wrapping.
s
Shouldn't happen. Post the code?
m
Copy code
Row(
    verticalAlignment = Alignment.CenterVertically
) {
    val duration = event.duration.toDuration()
    Column(modifier = Modifier.fillMaxHeight()) {
        Text("${duration.inWholeMilliseconds}ms", fontSize = 10.sp, modifier = Modifier.width(timeWidth.dp), color = color)
        Spacer(Modifier.weight(1f))
    }
    SelectionContainer {
        Text(event.sql, fontFamily = LocalAppFonts.current.JetbrainsMonoNL, modifier = Modifier.weight(1f))
    }
    IconButton(onClick = { sqlTraceVisible = !sqlTraceVisible }) {
        Icon(painterResource(Res.drawable.chevron_down), contentDescription = "Expand", modifier = Modifier.rotate(rotation))
    }
}
s
Include the full @Preview code where you see this break. This by itself looks fine. Also try without the
SelectionContainer
just in case that does anything wonky.
m
Should I be using @Preview anywhere? I'm just seeing this in my app at runtime. Removing the SelectionContainer seems to work, though I've got no clue why and being able to select that text is kind of crucial. Any suggestions?
s
I said preview just as an idea for me to be able to run this myself too. You can wrap the entire row with SelectionContainer as one idea
Seems like there was a bug around this https://issuetracker.google.com/issues/372053402, but it is marked as fixed, so I believe this should just work now
m
Moving the weight to the SelectionContainer does not work
s
Are you in a version which the issue mentions includes this fix or not?