material-components / material-components/material-components-android

[NavigationView] isVisible does not completely hide/show items

Open
#1,038 1 comment 0 reactions 1 assignee View on GitHub

@hunterstich is already working on this.

Since Apr 26, 2022.

bug Widget: NavigationView
Dominant language
Java
Stars
17.4k
Forks
3.2k
PR merge metrics
No merged PRs in 30d

Description

**Description:**
I have a problem with the menu of a `NavigationView`: i want to hide menu-items and re-show them later (e.g. login/logout buttons).

but when setting
```kotlin
menu.findItem(R.id.nav_login)?.isVisible = !isLoggedIn
menu.findItem(R.id.nav_logout)?.isVisible = isLoggedIn
```

the login-item is getting *invisible* instead of *gone* (and the logout-item does not show up at all).

To get it working, I need to click on an other item. and this other item needs to be in a group with `android:checkableBehavior="single"` (my login/logout items are in a group with `none`).

**Expected behavior:**
Items set to invisible should be *gone* and re-appear when set to be visible again without the need of clicking on an item in a `android:checkableBehavior="single"`-group.

**Material Library version:** 1.2.0-alpha04

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.