I've been messing with it for a while, but I can't...
# compose
s
I've been messing with it for a while, but I can't get
.focusProperties
to do anything on a Column, but works fine on a LazyColumn. Among other things, I tried adding
.focusGroup()
on the Column, and/or .focusTarget() on the children, but looks like there's something I'm not getting about the difference between Col and LazyCol. Is there a way to make to get Column to work with focus modifiers? (focusRestorer is what I'm eventually actually after)
z
I think focus properties is very broken. There’s a ticket for canFocus=false not applying to children, I’d link but not at computer atm
s
oh, this maybe?
l
I don’t know if that’s related, not sure I understand the initial question anyway: focusProperties {} applies to a focusTarget child - the goal of the API is to let you configure a focus target. Column doesn’t interact with the focus system at all - LazyLists (and scrollable internally) have a focus target inside, so they can scroll an item into view, receive key events to scroll, etc. If you add focusGroup() to the column, that sounds correct, but make sure to put the focusProperties on the left of the focus group so it applies to that
s
What I really want to do is set up a Column with
.focusRestorer()
so that child elements restore focus properly
l
I think
Modifier.focusRestorer().focusGroup()
should work in this case
s
oh.. could it just be that I got the order wrong?! I'm not sure I get why this order is that one that works
Omg! YES! this actually worked!! Thank you @Louis Pullen-Freilich [G] I can't believe in all my trial and error I didn't at least once get the order right even accidentally 😂 😅 🤦‍♂️
hmm ok it works in the simple case
Copy code
Row {
        Column(Modifier.focusRestorer().focusGroup()) {
            repeat(4) {
                Surface(onClick = {}) { Text(text = "row $it") }
            }
        }
        Button(onClick = { /*TODO*/ }) {
            Text("other row")
        }
    }
But I guess now I'm having more specific issues related to the fact I'm trying to put all this inside
<http://androidx.tv|androidx.tv>.material3.ModalNavigationDrawer