Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stackflow transition breaks when activity suspends longer than transitionDuration #472

Open
XiNiHa opened this issue Jul 2, 2024 · 1 comment

Comments

@XiNiHa
Copy link
Contributor

XiNiHa commented Jul 2, 2024

Currently, Stackflow activities' enter transition is only expressed with enter-active and enter-done. However, this doesn't work well with frameworks that do concurrent rendering because the core state update happens regardless of whether activities render synchronously or suspend during render. This results in something like this:

sequenceDiagram
    participant Core as @stackflow/core
    participant Integration as Integration (@stackflow/react)
    participant View
    View->>Core: push()
    activate Core
    note left of Core: Transition
    Core->>Integration: notify on subscribe() listener
    Integration->>Core: getStack()
    Core->>Integration: State with `enter-active`
    Integration->>View: Render new activity with `enter-active`
    activate View
    note right of View: Suspend
    Core->>Integration: notify on subscribe() listener
    deactivate Core
    Integration->>Core: getStack()
    Core->>Integration: State with `enter-done`
    Integration->>View: Rerender with `enter-done`
    deactivate View
    note right of View: Initial render with `enter-done`
Loading

As described above, if the view suspends longer than the core transition, the initial render of the view is done with enter-done state, resulting in broken CSS transitions.

To mitigate this, the core transition should be started after confirming that the initial view was rendered. These are the required parts to implement the feature:

  • Add a new transition state to express activities that didn't complete the initial render. (enter-pending?)
  • Add a new action that notifies the core after completing the initial render. (no idea about naming 🥲)

I'm willing to implement the feature after the direction is fixed.

Related: #434

@SimYunSup
Copy link
Contributor

Rather than adding a transition state, I think it's better to ditch the setInterval logic that changes from enter-active to enter-done and create an interface that can be manipulated in intergration. Additionally, I think it's okay to ditch the enter-active/enter-done state and just have the enter state. Currently, we can't manipulate the state inside core to respond to animationcancel event or React.Suspense, and I think it can better implement logic specific to each UI library if we touch the animation state in intergration.

example. react-toastify has item Map with ItemStatus, react-navigation's router has only current Route name with key, params

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants