android / android/nowinandroid

[Bug]: Bottom Bar Item is not highlighted in search

Open
#1,365 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Kotlin
Stars
21.8k
Forks
4.6k
Avg merge
19h 20m
Merged PRs (30d)
2

Description

### Is there an existing issue for this?

- [X] I have searched the existing issues

### Is there a StackOverflow question about this issue?

- [X] I have searched StackOverflow

### What happened?

When opening the search from any backstack, the highlighting of the navigation bar items is gone.

This issue is caused by usage of Destination.hierarchy for highlighting the bottom items.
Currently there is a Library-Restricted field NavHost.currentBackStack, which could be used instead.
Other than that highlighting of global destinations is not really possible, as far as I tried it.

I also found additional sources here:
https://cs.android.com/androidx/platform/frameworks/support/+/androidx-main:navigation/navigation-runtime/src/main/java/androidx/navigation/NavController.kt;drc=a35c4229c9b7643b15fcd5ddd0d81a7d9abbba4f;l=114

https://issuetracker.google.com/issues/308334893

I also already pinged Ian Lake, to get some answers on why this field is not public API and what would be his suggestion.
https://twitter.com/JPtaszyk/status/1777602817336684829

### Relevant logcat output

_No response_

### Code of Conduct

- [X] I agree to follow this project's Code of Conduct

Contributor guide

Open the contributing guide

Research direction

Start by tracing bottom-bar highlighting when search is opened from a back stack, focusing on Destination.hierarchy and the proposed NavHost.currentBackStack approach. Read the referenced AndroidX NavController.kt source and issue 308334893; done means navigation items remain highlighted for the relevant global and search destinations without relying on an unavailable API.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, kotlin
Domain
mobile
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.