Skip to content

NavigationView neglects to apply selection indicator in SelectedItem edge-case #643

@awaseru

Description

@awaseru

Invoke a NavigationViewItem, programmatically set NavigationView.SelectedItem to null, then re-invoke the NavigationViewItem. NavigationViewItem.IsSelected will be true, but the selection indicator will not appear on the left-side of the NavigationViewItem. Once a different NavigationViewItem is invoked, the selection indicator will work as expected for all items.

  • Windows 11 23H2
  • FluentAvalonia Version 2.2.0
  • Avalonia Version 11.2.1

Issue #579 is very similar. While closely rendering this as a duplicate, this issue is on non-nested NavigationView. Either way, the root cause may be the same. The erroneous code path is within AnimateSelectionChanged on this condition:

            if ((prevIndicator != nextIndicator) && paneContentGrid != null && prevIndicator != null && 
                nextIndicator != null && FAUISettings.AreAnimationsEnabled())

When animations are disabled, the selection indicator works as expected. Additionally, while observing the visual tree with DevTools, it appears the selection indicator is moved to the wrong NavigationViewItem (note it not visible on this item).

Image

In this screenshot, you can see that the Border of the SelectionIndicator is on (seemingly?) the wrong element. This incongruence doesn't always correspond to the item below, sometimes it is the item above. The accent colour is not blue in this application, that is the highlight from DevTools. 'Panel' is positioned as expected on the selected item.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions