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

NavigationView: Fix SelectedItem not being unset when no NavigationViewItem is selected #2329

Conversation

Felix-Dev
Copy link
Contributor

Description

Fix issue where NavView's SelectedItem property was not set to null when all navigation view items are no longer selected.

Motivation and Context

Fixes #957

How Has This Been Tested?

Added API test.

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label Apr 23, 2020
dev/Repeater/SelectionModel.cpp Outdated Show resolved Hide resolved
dev/Repeater/SelectionModel.cpp Show resolved Hide resolved
@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Apr 24, 2020

@ranjeshj VS seems to suggest you worked on this test so I'll ask you: Is the ValidateSelection call here really necessary? (That method is the previous ValidateSelectionChangedEvent() just renamed.) It seems to me we are validating whether item 4 has been selected two times. Do we need both checks?

Felix-Dev and others added 2 commits April 24, 2020 11:19
Co-Authored-By: Marcel Wagner <marcel.alex.wagner@outlook.com>
@marcelwgn
Copy link
Contributor

@ranjeshj VS seems to suggest you worked on this test so I'll ask you: Is the ValidateSelection call here really necessary? (That method is the previous ValidateSelectionChangedEvent() just renamed.) It seems to me we are validating whether item 4 has been selected two times. Do we need both checks?

I think the idea is that we verify that the selection is also correct when selectionchanged got raised.

@Felix-Dev
Copy link
Contributor Author

Felix-Dev commented Apr 24, 2020

@chingucoding I just don't think we need to check whether the selection is correct twice. If we keep the check in the SelectionChanged event handler I don't think we need the other check (as we fail if event was not raised).

@marcelwgn
Copy link
Contributor

@chingucoding I just don't think we need to check whether the selection is correct twice. If we keep the check in the SelectionChanged event handler I don't think we need the other check (as we fail if event was not raised).

We check if the selection is correct after we changed it and we also check if the selection is correct inside the SelectionChanged event. Techincally there could be a missmatch for example when we raise SelectionChanged to early.

@ranjeshj
Copy link
Contributor

hat method is

That does look redundant. One thing this might be checking is that the timing is correct - that the selection state has been updated before raising the event and checking the state in the event handler gives us the expected values. If that is not covered by any of the other tests, then a comment might be useful. If that is being covered elsewhere, we can remove the check. Thanks.

@ranjeshj ranjeshj added area-ItemsRepeater team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels Apr 24, 2020
@ranjeshj
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@Felix-Dev
Copy link
Contributor Author

I kept the SelectionChanged event handler ValidateSelection checks and removed the specific Select checks as they are covered in their own tests (ValidateOneLevelSingleSelection() and ValidateOneLevelMultipleSelection()).

@ranjeshj
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters StephenLPeters merged commit 9fd0861 into microsoft:master Apr 28, 2020
Kinnara added a commit to Kinnara/ModernWpf that referenced this pull request Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-ItemsRepeater team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NavigationView not resetting its SelectedItem if all items are unselected
6 participants