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

Back press handling after fold/unfold #118

Closed
CherryPerry opened this issue Aug 29, 2022 · 1 comment · Fixed by #119
Closed

Back press handling after fold/unfold #118

CherryPerry opened this issue Aug 29, 2022 · 1 comment · Fixed by #119
Assignees
Labels
bug Something isn't working

Comments

@CherryPerry
Copy link
Collaborator

Looks like there is slightly more to this – now a OnBackPressedCallback from a custom BackPressHandler plugin doesn't get invoked after onStop

Easiest way to repro this is in "Blocker" sample in sandbox, with same steps as before

Originally posted by @steelahhh in #102 (comment)

@CherryPerry CherryPerry added the bug Something isn't working label Aug 29, 2022
@CherryPerry CherryPerry changed the title Back press handling in background Back press handling after fold/unfold Aug 30, 2022
@CherryPerry
Copy link
Collaborator Author

This happens because of lifecycle callbacks order execution:

  1. The parent node is moved to STARTED and invokes its callbacks.
  2. ChildNodeLifecycleManager is the first to handle the event.
  3. ChildNodeLifecycleManager moves a child to STARTED.
  4. The child executes its own callbacks (order does not matter here).
  5. The child registers back press callback via OnBackPressedDispatcher.LifecycleOnBackPressedCancellable.onStateChanged.
  6. The parent proceeds to the next lifecycle observer which is OnBackPressedDispatcher.LifecycleOnBackPressedCancellable.onStateChanged.

After unfolding the order is different than before: child registers its callback before parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant