I'm having focus issues with ComposeView inside a RecyclerView (I started with Leanback's VerticalGridView, but to simplify I'm using RecyclerView for now).
The problem is that if my ComposeView internally doesn't contain anything focusable (a Text for example), the RecyclerView still moves focus to it when pressing DPAD_DOWN/UP.
Obviously this doesn't happen in a pure legacy recyclerview with Buttons and TextViews, so I tried setting
composeView.isFocusable = false
for those cases and that didn't work. I dug in deeper and found that a ComposeView usually has a single child: AndroidComposeView (src), so in my
onBindViewHolder
I put:
Copy code
holder.composeView.doOnAttach {
(it as ViewGroup).get(0).isFocusable = focusable
}
And that actually works, but is a terrible hack.
Is there a "proper" way to get this to work?
Hi all,
Was there any issue already created for this bug? We are facing a crash due to the same problem.
I’ve created a minimal repo to reproduce the crash here and filed a bug here.
Let me know if there’s already an existing issue, so I can close this one.