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

incorporate safe fallback destination to fix null destination causing UI flickering #1728

Merged
merged 2 commits into from
Dec 11, 2024

Conversation

trambui09
Copy link
Contributor

@trambui09 trambui09 commented Dec 10, 2024

Fixes #1675

When navigating to a destination lower in the hierarchy, the currentBackStackEntry temporarily becomes null due to the incremental update of the back stack by the NavController. This transient state causes UI elements, such as the Top Bar, to be removed and re-added, leading to a noticeable flicker.

A previousDestination fallback mechanism has been introduced. This approach ensures the UI maintains its state by retaining the last known valid destination when currentBackStackEntry is null. The following changes were made:

  • Added a previousDestination property that references the most recent non-null destination.
  • Updated the currentTopLevelDestination logic to use previousDestination to determine the active destination, ensuring the UI remains stable during transitions.
NiA-currentDestination-null-bug.mp4

Copy link
Collaborator

@dturner dturner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for investigating and fixing this 👍

@dturner dturner merged commit cb811ec into main Dec 11, 2024
2 checks passed
@dturner dturner deleted the trambui/navigation-null-debug branch December 11, 2024 11:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Why is currentDestination momentarily returned as null ?
2 participants