material-components / material-components/material-components-android
[BottomSheetDialogFragment + BottomNavigationView] weird behavior on navigation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 17.4k
- Forks
- 3.2k
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
I've got a menu with 4 items (Home, Search, Categories and Plus), the Plus item is the `BottomSheetDialogFragment`, whenever I click on it, it makes me navigate back to my `startDestination` (which is Home) and open the `BottomSheetDialogFragment`.
**Expected behavior:**
Open the `BottomSheetDialogFragment` on the screen I'm actually at.
**Source code:**
```kotlin
val host: NavHostFragment = supportFragmentManager
.findFragmentById(R.id.nav_host_fragment) as NavHostFragment? ?: return
val navController = host.navController
val toolbar = findViewById(R.id.toolbar)
val appBarConfiguration = AppBarConfiguration(
setOf(
R.id.homeFragment,
R.id.searchFragment,
R.id.categoriesFragment,
R.id.plusFragment
))
setSupportActionBar(toolbar)
val bottomNav = findViewById(R.id.bottom_nav_view)
bottomNav?.setupWithNavController(navController)
```
**Android API version:** 19
**Material Library version:** 1.2.0-alpha06
**Device:** Galaxy S3 Neo 4.4.2
**Additional Note**:
When I remove `R.id.plusFragment` from appBarConfiguration and use:
```kotlin
findViewById(R.id.plusFragment).setOnClickListener {
navController.navigate(R.id.plusFragment)
}
```
the `BottomSheetDialogFragment` is displaying correctly in the fragment I'm currently at.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the navigation flow with BottomNavigationView.setupWithNavController, NavHostFragment, AppBarConfiguration, and the BottomSheetDialogFragment on the stated Android API and Material Library versions. Compare the configured plusFragment item with the provided custom click-listener workaround. Done means the bottom sheet opens over the currently selected destination without returning to home.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100