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

Make consistency behaviour when clicking on a unselected item or clicking on a selected item #589

Merged
merged 1 commit into from
Apr 23, 2019

Conversation

licanhua
Copy link
Contributor

Fix #573
NavigationView has different logic for clicking on a selected item and click on unselected item.
We try to close the pane when clicking on unselected item which is implemented in ChangeSelection.
When clicked on a selected item, ChangeSelection is not called, but we have special logic in OnItemClick to know about it and raise ItemInvoked event to customer.
This fix would try to close pane for both cases, so I extract the code to ClosePaneIfNeccessaryAfterItemIsClicked, and call it in both ChangeSelection and OnItemClick.

@licanhua licanhua requested a review from a team as a code owner April 19, 2019 17:55
Copy link
Contributor

@kaiguo kaiguo left a comment

Choose a reason for hiding this comment

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

The fix looks good me. I guess my question is why selected and unselected item clicks go to different function? Can they be handled together in ChangeSelection?

@licanhua
Copy link
Contributor Author

The fix looks good me. I guess my question is why selected and unselected item clicks go to different function? Can they be handled together in ChangeSelection?
No, we can't.

Background:
Generally speaking, ItemInvoked and SelectionChanged event are raised from ListView, then NavigationView re-raise them to external customer.
In RS5, we introduced a lot of new features like SelectsOnInvoked, SelectionFollowFocus, and it makes the logic very complex. (see comments on NavigationView::OnSelectionChanged), during the refactoring, we delayed the itemInvoked to selectionchanged if it's not clicking on selecteditem. In this way, the mapping table is controlled inside SelectionChanged only, and it would be easy to read(reality is that I didn't see significant benefit).

So event looking like this:
Click on selected item -> ListView raise ItemInvoked -> NavView raise ItemInvoked
Click on un-selected item -> ListView raise ItemInvoked, and NavView ignore it -> ListView continue raise SelectionChanged event -> NavView handle selectionChanged -> NavView raise ItemInvoke -> NavView raise SelectionChanged.

When clicking on selected item, listview doesn't raise selectionchanged, so we can't move everything to ChangeSelection.

@licanhua licanhua added the auto merge This PR will be merged once all checks pass label Apr 22, 2019
@kaiguo
Copy link
Contributor

kaiguo commented Apr 23, 2019

The fix looks good me. I guess my question is why selected and unselected item clicks go to different function? Can they be handled together in ChangeSelection?
No, we can't.

Background:
Generally speaking, ItemInvoked and SelectionChanged event are raised from ListView, then NavigationView re-raise them to external customer.
In RS5, we introduced a lot of new features like SelectsOnInvoked, SelectionFollowFocus, and it makes the logic very complex. (see comments on NavigationView::OnSelectionChanged), during the refactoring, we delayed the itemInvoked to selectionchanged if it's not clicking on selecteditem. In this way, the mapping table is controlled inside SelectionChanged only, and it would be easy to read(reality is that I didn't see significant benefit).

So event looking like this:
Click on selected item -> ListView raise ItemInvoked -> NavView raise ItemInvoked
Click on un-selected item -> ListView raise ItemInvoked, and NavView ignore it -> ListView continue raise SelectionChanged event -> NavView handle selectionChanged -> NavView raise ItemInvoke -> NavView raise SelectionChanged.

When clicking on selected item, listview doesn't raise selectionchanged, so we can't move everything to ChangeSelection.

Thanks for clarifying!

@msft-github-bot msft-github-bot merged commit 363aa53 into master Apr 23, 2019
@msft-github-bot msft-github-bot deleted the user/canli/navviewminimal branch April 23, 2019 19:59
@jevansaks jevansaks added needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) and removed needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) labels May 30, 2019
jevansaks pushed a commit that referenced this pull request May 30, 2019
@msft-github-bot
Copy link
Collaborator

🎉Microsoft.UI.Xaml v2.1.190606001 has been released which incorporates this pull request.:tada:

Handy links:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto merge This PR will be merged once all checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NavigationView - In "Minimal" mode, clicking the SelectedItem does not close the menu flyout
4 participants