-
Notifications
You must be signed in to change notification settings - Fork 971
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 ListView is in virtual mode #3963
Fix ListView is in virtual mode #3963
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Viewed
d1dad32
to
562404f
Compare
97b4697
to
fa62c0d
Compare
src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs
Outdated
Show resolved
Hide resolved
src/System.Windows.Forms/src/System/Windows/Forms/ListViewItem.ListViewItemAccessibleObject.cs
Show resolved
Hide resolved
3bd1c21
to
85bcea6
Compare
Codecov Report
@@ Coverage Diff @@
## release/5.0 #3963 +/- ##
======================================================
- Coverage 67.87270% 37.07846% -30.79424%
======================================================
Files 1416 924 -492
Lines 507889 250984 -256905
Branches 41298 36986 -4312
======================================================
- Hits 344718 93061 -251657
+ Misses 156983 152461 -4522
+ Partials 6188 5462 -726
Flags with carried forward coverage won't be shown. Click here to find out more. |
85bcea6
to
efda3fd
Compare
efda3fd
to
e8db5db
Compare
src/System.Windows.Forms/tests/UnitTests/System/Windows/Forms/ListViewTests.cs
Outdated
Show resolved
Hide resolved
ad29a5d
to
2a42c89
Compare
src/System.Windows.Forms/src/System/Windows/Forms/ListView.ListViewAccessibleObject.cs
Outdated
Show resolved
Hide resolved
...System.Windows.Forms/src/System/Windows/Forms/ListViewGroup.ListViewGroupAccessibleObject.cs
Outdated
Show resolved
Hide resolved
_owningListView = owningGroup.ListView ?? throw new InvalidOperationException(nameof(owningGroup.ListView)); | ||
_owningListView = owningGroup.ListView | ||
?? (owningGroup.Items.Count > 0 && _owningGroup.Items[0].ListView != null | ||
? _owningGroup.Items[0].ListView | ||
: throw new InvalidOperationException(nameof(owningGroup.ListView))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -23,7 +23,7 @@ internal class ListViewItemAccessibleObject : AccessibleObject | |||
public ListViewItemAccessibleObject(ListViewItem owningItem, ListViewGroup? owningGroup) | |||
{ | |||
_owningItem = owningItem ?? throw new ArgumentNullException(nameof(owningItem)); | |||
_owningListView = owningItem.ListView ?? throw new InvalidOperationException(nameof(owningItem.ListView)); | |||
_owningListView = owningItem.ListView ?? owningGroup?.ListView ?? throw new InvalidOperationException(nameof(owningItem.ListView)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
b858c97
to
3c65c95
Compare
During implementation of accessible objects for ListView we started to use SelectedItems property for getting of required items. Unfortunately, this property is not available when the ListView is in virtual mode. As result we got an exceptions when tried to do any UI action when ListView is in virtual mode. As a fix, we implemented using SelectedIndices instead of SelectedItems when getting Accessible Objects, because SelectedIndices property is available in any mode. Also we added a check for methods in ListViewGroup that the ListView is not in virtual mode, since ListViewGroups are not supported for virtual mode. Besides we replaced "groups.Count > 0" condition on "GroupsEnabled" in logic for navigation on ListView by keyboard. Together with the "groups.Count > 0" condition, it also checks that Groups is displayed and ListView is in default (not virtual) mode
…roperty Original implementation for ExpandCollapseState is not valid because ListViewGroupCollapsedState can have Default (Non-collapsible) state. In this case user will see that group has "Collapsed" state, although the group does not support collapsing. As result logic for ExpandCollapseState property was updated. If group has "Collapsed" state then we return "Collapsed" else we return "Expanded" for "Expanded" and "Default" states
If a ListViewItem is in a collapsed ListViewGroup and we try to select it in Inspector then we get exception. It happens because during trying to get "Bounds" property we send a "GETITEMRECT" message to NativeControl and receive empty result. To avoid this issue, we added the condition that if a ListViewItem is located in a ListViewGroup and this ListViewGroup is collapsed we return empty rectangle otherwise we call old logic for getting of rectangle
The "SelectedIndexies.Contains" method tries to get ListViewItem using the index from parameter and checks "Selected" property for this ListViewItem. If we close the dialog that contains ListView then ListView is still available to us in the inspector, but ListViewItem will have index with "-1" value. As result if we call "SelectedIndexies.Contains" method for ListViewItem with such index then we get an exception. As a fix we added check that the index should be greater than -1 and less than the number of Items in the ListView. If check is failed then we will return false, otherwise we will get the ListViewItem using index and check "Selected" property
9945bc4
to
bc28874
Compare
Related to PR dotnet#3963 and PR dotnet#3224 Fix keyboard Narrator announcing the check/uncheck state of ListView item when enabling ListView CheckBoxes property Fixes Issue dotnet#4029
Fixes #3962
Proposed changes
Customer Impact
ListView in virtual mode
During implementation of accessible objects for ListView we started to use "SelectedItems" properties for getting of required items. Unfortunately, "SelectedItems", "CheckedItems" and partially "Items" properties are not available when the ListView is in virtual mode. If trying to get any properties/methods from "SelecedItems", "CheckedItems" or get enumerator of "Items" then ListView throws IOE in virtual mode. As result we got an exceptions when tried to do any UI action when ListView is in virtual mode.
After fixing issue with ListView in a virtual mode, it is again available for navigation and UI interaction:
ListViewGroup.ListViewGroupAccessibleObject.ExpandCollapseState
The ExpandCollapseState is not valid for non-collapsible ListViewGroup. User sees that such group has "Collapsed" state although the group cannot be collapsed:
After fixing, ExpandCollapseState is valid for non-collapsible ListViewGroup:
ListViewItem.ListViewItemAccessibleObject.Bounds
If a ListViewItem is in a collapsed ListViewGroup and user tries to selects it in Inspector then user will see exception:
After fixing, user can see data about ListViewItem in a collapsed ListViewGroup without application exception:
Regression?
Risk
Test methodology
Test environment(s)
Accessibility Testing
Microsoft Reviewers: Open in CodeFlow