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

Fix issue with single select and unrealized children on TreeView #2547

Conversation

marcelwgn
Copy link
Collaborator

Description

When a selected item is being expanded and it is using virtualization (i.e. HasUnrealizedChildren), the items will get set to "selected". This is wanted in multi select, however in single select this moves the selection, which is not the intended behavior.

This get's fixed by only updating the child item's selection when we are in multi select.

Motivation and Context

Fixes #1820 , Fixes #2463

How Has This Been Tested?

Add new interaction test.

Screenshots (if appropriate):

@msft-github-bot msft-github-bot added the needs-triage Issue needs to be triaged by the area owners label May 25, 2020
@ranjeshj ranjeshj added area-TreeView needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) team-Controls Issue for the Controls team and removed needs-triage Issue needs to be triaged by the area owners labels May 27, 2020
@@ -1040,7 +1040,12 @@ void ViewModel::SelectedNodeChildrenChanged(winrt::TreeViewNode const& sender, w
case (winrt::CollectionChange::ItemInserted):
{
auto newNode = changingChildrenNode.Children().GetAt(index);
UpdateNodeSelection(newNode, NodeSelectionState(changingChildrenNode));

// If we are in multi select, we want the new child items to be also selected.
Copy link
Contributor

Choose a reason for hiding this comment

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

// If we are in multi select, we want the new child items to be also selected. [](start = 8, length = 78)

I assume that the desired behavior is not dependent on the 'HasUnrealizedChildren' flag. That is, when all the children are realized and we expand a node we would behave the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

@chingucoding do you know if this is the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As far as I know this method would handle both cases regardless of the HasUnrealizedChildren flag. This listener just acts when the children of the selected node have changed. However in the case of HasUnrealizedChildren, those children got added to the selected item, raising this listener. Since in SingleSelect, selecting an item unselects the previous item, this resulted in the faulty behavior.

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

@chingucoding looks like there is a merge conflict now :/

@marcelwgn
Copy link
Collaborator Author

Merge conflict should be resolved now. Thanks for the ping!

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters
Copy link
Contributor

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@StephenLPeters StephenLPeters merged commit eb6d418 into microsoft:master Jun 3, 2020
ranjeshj pushed a commit that referenced this pull request Jul 7, 2020
* Add test page

* Add test

* Fix the issue

* Clean up tests

* Remove empty line
@ranjeshj ranjeshj removed the needs-cherrypicktorelease PR tagged for cherry-pick to the current release branch (but not yet picked) label Aug 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-TreeView team-Controls Issue for the Controls team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expand messes up selected item The selected node of TreeView will be automatic change when expand
4 participants