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

RemoveAtEnd on TreeViewNodeVector broken #10239

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

galenelias
Copy link

Ported an app from UWP to WinUI3 and noticed a bunch of UI 'corruption' in our TreeView control when filtering elements. Tracked it down to TreeView.RootNodes().RemoveAtEnd() always removing the first item instead of the last item, which means you are left with a totally unexpected result, as well as being unable to remove all the items due to never being able to remove index 0.

The bug is due to incorrect parameter passing (ideally unused stack variable warnings would be enabled and would catch this), where index was intialized, but never passed to RemoveAt, causing the updateItemsSource boolean to stand in for an index, causing us to always delete index 0 or 1 instead of N-1.

The workaround is to just manually use RemoveAt instead of RemoveAtEnd.

Description

Pass index to RemoveAtIndex call.

Motivation and Context

RemoveAtEnd is totally unusable on TreeView Nodes collections.

How Has This Been Tested?

I have not built or tested this, as the links to setting up and building this repo in the Setup and build environment section of the contributing document is a dead link, and the change is pretty straightforward.

Screenshots (if appropriate):

N/A

Ported an app from UWP to WinUI3 and noticed a bunch of UI 'corruption'
in our TreeView control when filtering elements. Tracked it down to
TreeView.RootNodes().RemoveAtEnd() always removing the first item
instead of the last item, which means you are left with a totally
unexpected result, as well as being unable to remove all the items due
to never being able to remove index 0.

The bug is due to incorrect parameter passing (ideally unused stack
variable warnings would be enabled and would catch this), where index
was intialized, but never passed to RemoveAt, causing the
`updateItemsSource` boolean to stand in for an index, causing us to
always delete index 0 or 1 instead of N-1.

The workaround is to just manually use RemoveAt instead of RemoveAtEnd.
@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-triage Issue needs to be triaged by the area owners
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant