Repository navigation
Conversation
|
Tick the box to add this pull request to the merge queue (same as
|
|
The build 245548 found UI Test snapshots differences: Details
|
b21d4b0 to
13dd4d5
Compare
| foreach (var container in MaterializedContainers) | ||
| { | ||
| if (container is SelectorItem selectorItem && IndexFromContainer(container) is var index and >= 0) | ||
| { | ||
| selectorItem.IsSelected = _selectedItems.Contains(ItemFromIndex(index)); | ||
| } | ||
| } |
| foreach (var container in MaterializedContainers) | ||
| { | ||
| if (container is ListBoxItem { IsSelected: true } listBoxItem) | ||
| { | ||
| listBoxItem.UpdateVisualState(true); | ||
| } | ||
| } |
| catch (Exception) | ||
| { | ||
| return; | ||
| } |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245622 found UI Test snapshots differences: Details
|
13dd4d5 to
3f60a9b
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245656 found UI Test snapshots differences: Details
|
3f60a9b to
466ca06
Compare
XAML Styler drift detected on
|
| catch (Exception ex) | ||
| { | ||
| Log($"SelectAll threw {ex.GetType().Name}"); | ||
| } |
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245689 found UI Test snapshots differences: Details
|
466ca06 to
06595d2
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 245974 found UI Test snapshots differences: Details
|
morning4coffe-dev
left a comment
There was a problem hiding this comment.
Compared ListBox.mux.cs against ListBox_Partial.cpp (winui3/release/1.8.4, dc46907e; the file is identical to the b1db157 cited in the header). OnKeyDown, HandleItemSelection, OnSelectionChanged, ChangeVisualState, the focus handlers, SelectAll and MakeRangeSelection (default anchor 0) match, and the "Uno specific" deviations are all marked. A few differences, none blocking:
- Anchor on
Replace/Move(OnItemsSourceSingleCollectionChanged). InListBox::OnItemsChanged,ItemChangedonly clears the anchor whenindex == *m_pAnchorIndex. Here everyReplaceandMovesetsm_pAnchorIndex = null, so replacing an unrelated item loses the anchor and a later Shift-click range starts from 0.Add/Removeare correct (including the multi-item generalisation).Replacecould clear only when the replaced range contains the anchor, andMovecould be treated as remove + insert. - Click path ignores the focus result.
ListBox::OnSelectorItemClickedcallsFocus(FocusState_Pointer)and only runsHandleItemSelectionif (*pFocused), then callsSetExpectingGotFocusEventFromParentInteraction(TRUE)when the item newly got focus.SelectorItem.OnPointerReleasedPrivateignores the return value ofFocus(FocusState.Pointer)beforeOnItemClicked, so a non-focusable item still selects. The comment onOnItemClickedacknowledges the split; it may be worth gating on the result (that code is shared with ListView/ComboBox). - Selection is keyed by item, not index. WinUI's
m_selectionholds indices;SelectedItemshere compares withEquals, so equal items (e.g. duplicate strings) share one entry. Documented and consistent withListViewBase, but is there a test for duplicates? HandleItemSelectionleaves theElementSoundKind.Invokerequest as a TODO (the C++ callsRequestInteractionSoundForElement).
Not reviewed: VirtualizingStackPanel.managed.cs, the Selector_Partial.cs and ComboBox.custom.cs changes, and the test files.
VirtualizingStackPanel threw from GetLayouter on Skia, so any ItemsControl using it, like the default ListBox template, showed no items. Under a Selector it now borrows ItemsStackPanelLayout, like CarouselPanel, and creates it only then; under a plain ItemsControl, which adds the containers itself, it stacks them without virtualizing, as WinUI does. Orientation is implemented. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Moves it to Selector so other selectors on a virtualizing panel can use it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Ports ListBox_Partial.cpp: ListBoxItem containers, SelectionMode (Single, Multiple, Extended with an anchor), SelectedItems, SelectAll, SingleSelectionFollowsFocus, ScrollIntoView, and keyboard navigation and selection. Uno's Selector has no multi-selection store, so, as in ListViewBase, SelectedItems holds it and SelectedIndex/SelectedItem follow its first item; item changes, SelectionMode and ItemsSource changes, and app changes to SelectedItems behave as on WinUI. Selector's checks for its subclasses become virtual members, so UI Automation's AddToSelection/RemoveFromSelection work for a ListBox too. Fixes #1362 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A manual test page for the selection modes: clicks with modifiers, the keyboard, SingleSelectionFollowsFocus, SelectAll and item insertions, with the selection and the SelectionChanged events shown next to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
06595d2 to
41f25fd
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
The build 249141 found UI Test snapshots differences: Details
|
GitHub Issue: closes #1362
PR Type:
🐞 Bugfix
What changed? 🚀
On Skia,
ListBoxwas mostly a stub:VirtualizingStackPanelthrew fromGetLayouter, so the list rendered empty.StackPanelas the items panel, there were noListBoxItemcontainers, so clicks selected nothing.SelectedItems,SelectionMode,SelectAll,ScrollIntoViewandSingleSelectionFollowsFocuswere[NotImplemented], andSelectedItemsthrew.VirtualizingStackPanelSelectorit now borrowsItemsStackPanelLayout, asCarouselPanelalready does, so the defaultListBoxtemplate virtualizes. The layout is created only when the panel virtualizes.ItemsControl, which adds the containers itself, it stacks them without virtualizing. WinUI behaves the same way: there, a plainItemsControlwith aVirtualizingStackPanelrealizes every item.Orientationis implemented. WinUI's own layout is still not ported.ListBoxThis is a port of
ListBox_Partial.cpp(ListBox.mux.cs):ListBoxItemcontainers.SelectionModeSingle, Multiple and Extended. Extended has anchor-based Shift and Ctrl+Shift ranges, and Ctrl toggles.SelectedItems,SelectAll,SingleSelectionFollowsFocusandScrollIntoView.SelectionModeclears the selection, as WinUI does: itsUpdateCVSynchronizationStateresetsSelectedItem. TheSelectionChangedevents match WinUI's: Multiple → Single first trims the selection to one item, then clears it, so it raises two.ItemsSourceclears the selection, as WinUI does, including the items that the new source shares with the old one.SelectAllin Single mode throwsNotSupportedException(WinUI:E_NOT_SUPPORTED).Uno's
Selectorhas no multi-selection store; WinUI keeps it inSelector::m_selection. So, as inListViewBase,SelectedItemsholds the selection in Multiple and Extended mode, andSelectedIndex/SelectedItemfollow its first item (ListBox.Selection.cs). These behaviors were checked against native WinUI:SelectedIndex/SelectedItemset from code in Multiple or Extended mode select just that item. ASelectedItemvalue that isn't in the items is rejected, and the selection is left as it was.SelectedItems:InvalidOperationException; WinUI fails them withE_UNEXPECTED.SelectedItemsuntil the next selection change; Uno drops it right away.["a", "a", "b"]) share oneSelectedItemsentry, as inListViewBase. Ctrl+A therefore checks that every item is selected rather than comparing the counts, so a second Ctrl+A deselects them.SelectionChangedhandler can changeSelectedItems, as on WinUI, even with anotherCollectionChangedhandler attached. TheListBoxnow syncs after the collection's handlers, outside ofObservableCollection's reentrancy block. So an app'sSelectedItems.CollectionChangedhandler still sees the previousSelectedIndex/SelectedItem;SelectionChangedcomes after it with the new ones.SelectedIndexset beforeItemsSource(as in markup) is applied once the items are available, in every mode, as WinUI does.ListBoxItem.IsSelectedset from code in Multiple mode adds or removes just that item.Selectorand automationScrollIntoViewand theSelectedItemsfiltering log at Debug level when they ignore a request, andVirtualizingStackPanellogs once when it stacks without virtualizing.Selectorno longer checks forListViewBase,ComboBoxandListBoxby type. Those classes override three new members:MultiSelectionItems(nullfor a single selection);ScrollsSelectionIntoView;ScrollItemIntoView.AddToSelection,RemoveFromSelection,IsSelectedandSelectorAutomationPeer's selection useMultiSelectionItems, so they also work for aListBox, and follow the selection mode.ComboBox's managedScrollIntoView(fast path, then a layouter fallback) moved toSelector, so thatListBoxcan share it.Validation
Given_ListBoxandGiven_VirtualizingStackPanelcases cover:ScrollIntoView;SelectedIndex↔SelectedItems, andSelectedItemschanges raisingSelectionChanged;SelectedIndex/SelectedItemset in a multi-selection mode;SelectedItemschanges with another handler attached, and in Single mode;SelectionChangedevents, and replacingItemsSource;SelectAll(also on 5,000 items), and Ctrl+A with equal items;SelectedItemschanged from aSelectionChangedhandler,SelectedIndexset beforeItemsSource,ListBoxItem.IsSelectedset from code;VirtualizingStackPanel↔StackPanel);SingleSelectionFollowsFocus=false.SelectAllcase and theVirtualizingStackPanel-in-a-ScrollViewercase pass both ways; they are regression guards.Given_AccessibleListView'sAddToSelectioncase now also runs forListBox.SelectedItemschange: 287 passed, 0 failed, 21 skipped, 1 inconclusive. It coveredGiven_ComboBox,Given_FlipView,Given_ListViewBase,Given_Selector,Given_Control,Given_AccessibleListView,Given_AccessibleComboBox,Given_ItemsStackPanel,Given_ListBoxandGiven_VirtualizingStackPanel. The inconclusive one isWhen_Large_List_Scroll_To_End_Then_Back_Up_TryClick.Given_ListBox,Given_VirtualizingStackPanel,Given_AccessibleListView,Given_ComboBox,Given_FlipViewandGiven_Selector: 111 passed, 0 failed, 6 skipped.Given_ListViewBaseandGiven_ListViewBase_Itemswere run with that set one step earlier, before a lastListBox-only fix: no failures besides the case that fix addressed, 1 inconclusive (When_Large_List_Scroll_To_End_Then_Back_Up_TryClick)./winui-runtime-tests):Given_ListBox,Given_VirtualizingStackPaneland theAddToSelectioncases: 33/33 pass.SingleSelectionFollowsFocus=false) and touch-hold cases are Uno-only, because the test input helpers can't hold modifiers on WinUI. So the click and keyboard selection semantics follow the WinUI source but weren't compared against WinUI at runtime.SelectionModechange or anItemsSourcereplacement, applying aSelectedIndexset before the items, and how it handles app changes toSelectedItems.ListBox_SelectionModessample (categoryListBox) switches the selection mode and shows the selection and theSelectionChangedevents.Given_ListBox,Given_VirtualizingStackPanelandGiven_AccessibleListView: 40 passed, 1 skipped (a mobile-only peer test). The click-with-modifiers, keyboard and touch-hold cases ran there.Not in this PR
ItemsControlwith anItemsStackPanelgets its containers from both theItemsControland the panel's layout: fix(itemscontrol): Don't duplicate ItemsStackPanel containers #26333, stacked on this PR.ItemCollection's indexer setter (Items[i] = x) raises no change notification, so noItemsControlsees that replacement. This predates the PR; fixed separately by fix(itemcollection): Raise VectorChanged when an item is replaced #26348.ComboBoxdoes, which recycles the focused container. fix(itemscontrol): Don't duplicate ItemsStackPanel containers #26333 forwards them to the layout incrementally instead.ElementSoundPlayerinteraction sound on item selection (TODO UnoinHandleItemSelection).PR Checklist ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code