https://kotlinlang.org logo
Title
s

Stuie

07/23/2022, 11:10 PM
Hey, I'm emitting some values via state flow, and one of the windows in my multi-window app collects that state in order to show information. Whenever a new value is emitted, the window containing the composable that collects the flow takes focus. I didn't configure this behavior, and I'm struggling to find how to prevent it. When I search Google I just get a lot of results about Jetpack Compose and text fields taking focus. To be clear, I need the window to be up to date, as it will still be visible beside the focused window, I just don't want focus to change when something is emitted/collected via state flow. How can I achieve this?
z

Zach Klippenstein (he/him) [MOD]

07/24/2022, 5:31 PM
Is there a focusable composable in the window? Can you share a minimal reproducer?
s

Stuie

07/24/2022, 5:39 PM
I'll check to make sure nothing in the window is focusable, and if that doesn't sort it out I'll create a minimal reproducer.
I couldn't reproduce it with a simple project. I suspect this may be related to Decompose at this point, as that's the major remaining difference between my real app and my repro app.
a

Arkadii Ivanov

07/25/2022, 7:28 AM
Please note, Decompose itself doesn't depend on Compose. There is extensions module for Compose but there is no windows API. When I worked with Compose windows on my own, I noticed some weird behavior as well. E.g. a non-modal window appeared behind the main window. And there were focus issues as well.
So, I believe it should be reproducible without Decompose as well, if you replace
Value<ChildStack<>>
with
State<List<>>
and just update the stack manually.
s

Stuie

08/03/2022, 6:41 PM
Hi, just to follow up on this, I tried removing Decompose from my app, and I can confirm that the weird focus issue still occurs. I may continue with the small test app I built to see what other difference is causing this.