vide
10/13/2023, 11:52 AMBringIntoViewRequester.bringIntoView()
supposed to cancel the previous animation? When moving focus to an off-screen element, I first get an animation automatically triggered by FocusableNode.onFocusEvent
, and only after it has completed my own request (with a padded rect) is ran.bringIntoView
before the FocusableNode does...Zach Klippenstein (he/him) [MOD]
10/13/2023, 1:05 PMvide
10/13/2023, 2:01 PMZach Klippenstein (he/him) [MOD]
10/13/2023, 2:03 PMvide
10/13/2023, 2:19 PM// simplified code but you should get the general idea
fun Modifier.scrollOnFocus(...) = Modifier.onFocusChanged { if (it.hasFocus) bringIntoViewRequester.bringIntoView(paddedRect) }
@Composable fun FocusableChunk() = Box(Modifier.scrollOnFocus().focusGroup()) { content() }
FocusableChunk can be then wrap any "sections" that should usually be visible at once if even one node inside it has focus, like a TV media row but more stuff in it.
Currently it looks like onFocusChanged is called first for the parent (ActiveParent) before the activated node (Active) itself which makes timings difficult. The execution order might be unpredictable anyways as the calls are launched into coroutines.Zach Klippenstein (he/him) [MOD]
11/08/2023, 3:35 PM