https://kotlinlang.org logo
Title
a

Adam Brown

01/31/2023, 5:05 AM
I got a weird one here. So when using an animation with the
Children
composable, it subtly breaks certain things. I don't have a minimal case repro yet, but let me explain:
Children(
		modifier = modifier,
		stack = routerState,
		animation = stackAnimation { _, _, _ -> fade() },
	) {
		when (val child = it.instance) {
			is ProjectRoot.Destination.EditorDestination ->
				ProjectEditorUi(component = child.component, isWide = isWide, drawableKlass = drawableKlass)

			is ProjectRoot.Destination.NotesDestination -> {
				var textValue by remember { mutableStateOf("imagine this is enough text to make this scrollable") }
				// Try to scroll this textField with the middle mouse button on desktop after switching to it
				TextField(
					modifier = Modifier.fillMaxSize(),
					value = textValue,
					onValueChange = { textValue = it },
				)
			}

			is ProjectRoot.Destination.EncyclopediaDestination ->
				EncyclopediaUi(child.component)
		}
	}
So the middle one there, say it has enough text to be scrollable. When you switch to it and it plays the fade animation, then hover over it with your mouse and scroll it with your middle mouse button, you'll note it doesn't scroll.
Then just comment out the animation parameter to
Children
and try again, see that it does scroll now.
I've seen this cause a separate but very similar problem where my state updates a lazy grid, but the UI doesn't actually update. If I resize the window, then it'll update.
In both cases the state is updating behind the scenes, but the recomposition isn't happening to actually show it
I don't see this happening on Android clients, so it's probably a compose desktop issue
I'm testing on Windows right now, i can try on a Linux box later and see if it's the same
a

Arkadii Ivanov

01/31/2023, 7:58 AM
Thanks, a reproducer would help here. Also maybe add
scrollable
modifier?
a

Adam Brown

01/31/2023, 5:22 PM
ya I'l try to get one put together tonight
TextField
doesn't need scrollable though, in fact it breaks TF's own built in scrolling if you add one
a

Arkadii Ivanov

02/04/2023, 1:40 PM
This appears to be a bug in Compose - https://github.com/JetBrains/compose-jb/issues/2696 Basically,
Children
function uses
movableContentOf
, which breaks scrollable content inside it on switching. Here is the related Decompose bug for tracking - https://github.com/arkivanov/Decompose/issues/326