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

[FR]: Use navigateUp() Instead of popBackStack() for Toolbar Up Button Click #1817

Open
2 tasks done
imjoz opened this issue Jan 26, 2025 · 2 comments
Open
2 tasks done
Labels
enhancement New feature or request

Comments

@imjoz
Copy link

imjoz commented Jan 26, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem

I recently reviewed the principles of navigation in Compose. From what I understand, the top app bar’s “Up” navigation button should call navController.navigateUp() rather than popBackStack(), which is intended for handling the device’s back press.

However, in the NiaNavHost, the onBackClick callbacks in various screens are currently using popBackStack(). My understanding is that onBackClick is hoisted to handle the toolbar’s “Up” button clicks in these screens.

The current implementation using popBackStack() works as expected. However, I would like to understand whether using navigateUp() might be a more appropriate approach.

Describe the solution

Current

topicScreen(
    showBackButton = true,
    onBackClick = navController::popBackStack,
    onTopicClick = navController::navigateToTopic,
)

Proposed

topicScreen(
    showBackButton = true,
    onNavigateUp = navController::navigateUp,
    onTopicClick = navController::navigateToTopic,
)

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct
@imjoz imjoz added the enhancement New feature or request label Jan 26, 2025
@akash0228
Copy link

if anyone confirms i can work on it

@imjoz
Copy link
Author

imjoz commented Jan 31, 2025

Thanks @akash0228, I already have a PR line-up after I created the issue, I was also waiting for the confirmation, cheers ✨

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

No branches or pull requests

2 participants