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

Select correct item in navigation upon opening item from search #478

Merged

Conversation

marcelwgn
Copy link
Collaborator

Description

When the users searches an item, we are now searching for the correct NavigationViewItem and setting it as the selected item. Unfortunately, we need to find the corresponding NavigationViewItem to update selection.

Motivation and Context

Closes #420

How Has This Been Tested?

Tested manually by trying both display orientations and searching for a control and visiting the page through the search

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Copy link

@YuliKl YuliKl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First of all, I love this feature. Thank you @chingucoding for adding the code!

I suspect that I'm seeing some rendering glitches when the newly selected item is off screen. The viewport window doesn't move, and when I manually scroll down (or up), the selected item is missing its selection indicator. I would not be at all surprised if this behavior is a limitation in NavigationView's implementation. Some of this might be mitigated by collapsing all categories other than the parent of the now-selected item.

While I think this fix is not perfect, I believe the new behavior is much better than what we have today.

@marcelwgn
Copy link
Collaborator Author

Yes unfortunately, a lot of this code is somewhat a workaround. Maybe it is worth discussing on the WinUI repository, if we want to adjust the behavior in that regard?

Regarding the not scrolling the selecteditem into view, fixing this here would require us to walk the visual tree, and get the scrollviewer ourselfes, which doesn't sound like a good idea.

@YuliKl
Copy link

YuliKl commented Jul 29, 2020

Probably a good idea to start a conversation about this in the WinUI repo. XCG serves as a proving ground for our controls and your change is highlighting some issues with the hierarchical navigation implementation.

I would definitely avoid doing something unnatural like walking the visual tree ;)

@marcelwgn
Copy link
Collaborator Author

marcelwgn commented Jul 30, 2020

@YuliKl. I've created microsoft/microsoft-ui-xaml#3015 to discuss whether the NavigationView behavior should change in that regard.

@marcelwgn
Copy link
Collaborator Author

@YuliKl I've added the BringIntoView call as suggested by @StephenLPeters , and the selected item will now be on screen, regardless if it was previously on screen or not.

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

Successfully merging this pull request may close these issues.

Page navigation from search should expand TreeView and select page
3 participants