-
Notifications
You must be signed in to change notification settings - Fork 706
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
The selected node of TreeView will be automatic change when expand #1820
Comments
@zhuxb711, thanks for reporting this issue. I was not able to reproduce the issue myself. Could you please share a repro app with us? Could you also please clarify how you are interacting with the TreeView? Are you using mouse or keyboard? Thanks. |
@kmahone I'm using mouse to interact. I make a demo for you, this problem does exist. &If I select parent node and then expand it, the selection will be changed to its subnode. Tips: Before you run the demo, please granting "file system access" in system setting for demo |
Thanks @zhuxb711 I can reproduce the issue now. |
@kaiguo can you please take a look to determine the root cause here and come up with a workaround if possible. |
@kmahone This problem is very confusing to my users and hopes to be fixed as soon as possible |
I want to know when this problem can be fixed @kmahone |
@zhub711 there have been some fixes to TreeView, can you see if the issue repros in the latest prerelease (went out today). @kaiguo did you get a chance to look at this ? |
I have installed the latest preview version and tested this issue, it still exists and has not been fixed @ranjeshj |
This is really weird behavior. I'm not sure yet why the expansion and populating of the children collection would affect the selection state. @zhuxb711 One hacky workaround to unblock you could be to save and restore the selection after the expand operation like so. var oldSelectedNode = FolderTree.SelectedNode; |
@ranjeshj not 100% sure but it probably has something to do with this, microsoft-ui-xaml/dev/TreeView/TreeViewList.cpp Lines 356 to 359 in ca95be6
I think this code was added to reverse some ListView selection changes we didn't want when using databinding. The demo code works on TreeNode directly and doesn't use ItemsSource binding. Perhaps we should execute the code block above only in content mode so adding an extra |
@kaiguo You probably should test it yourself but I went ahead and added your suggestion to the TreeViewList, then built a nuget package of WinUI and used it on the repro app. Result: I'm still seeing the same erroneous selection change behavior reported here. |
@chingucoding Thanks for the PR. @StephenLPeters can you please review this PR ? Thanks! |
Describe the bug
The selected item in TreeView will be automatic change when expand
Steps to reproduce the bug
Steps to reproduce the behavior:
Expected behavior
The selected node of TreeView should not be changed
Screenshots
Version Info
NuGet package version:
2.3.191211002
Additional context
The text was updated successfully, but these errors were encountered: