Skip to content

BackStackScreen causes ComposeRenderings to disappear when transition animations kick-in #669

@tudorluca

Description

@tudorluca

I've changed ":samples:compose-samples" & ":samples:tutorial" to play with BackStackScreen, ComposeRendering & LayoutRunners. The code producing this bug isn't really noteworthy. The whole Activity is driven with a WorkflowLayout and the render method looks like:

  override fun render(
    renderProps: Unit,
    renderState: State,
    context: RenderContext
  ): Any {
    val backstack: List<Any> = List(renderState.children) { index ->
      when (index % 3) {
        0 -> {
          LegacyRendering(
            id = "$index Compose-GoForwardRendering",
            goBack = { context.actionSink.send(goBack()) },
            goForward = { context.actionSink.send(goForward()) },
            rendering = GoForwardComposeRendering(
              step = index,
              content = context.renderChild(TextInputWorkflow, key = "text-input-$index"),
              onNextClicked = { context.actionSink.send(goForward()) },
            ),
          )
        }

        1 -> {
          val welcomeScreen = context.renderChild(WelcomeWorkflow, key = "welcome-$index") {
            WorkflowAction.noAction()
          }
          LegacyRendering(
            id = "$index Legacy-Welcome Screen",
            goBack = { context.actionSink.send(goBack()) },
            goForward = { context.actionSink.send(goForward()) },
            rendering = welcomeScreen,
          )
        }

        else -> {
          val hello = context.renderChild(HelloWorkflow)
          LegacyRendering(
            id = "$index Compose-GoBackRendering",
            goBack = { context.actionSink.send(goBack()) },
            goForward = { context.actionSink.send(goForward()) },
            rendering = GoBackComposeRendering(
              step = index,
              content = hello,
              onGoBack = { context.actionSink.send(goBack()) },
            )
          )
        }
      }
    }

    return backstack.toBackStackScreen()
  }

Here's a short video showcasing the problem:

Compose-BackStackScreen.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions