-
Notifications
You must be signed in to change notification settings - Fork 628
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
Select correct item in navigation upon opening item from search #478
Conversation
There was a problem hiding this 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.
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. |
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 ;) |
@YuliKl. I've created microsoft/microsoft-ui-xaml#3015 to discuss whether the NavigationView behavior should change in that regard. |
@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. |
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