Skip to content

fix(itemcontainer): mute internal pointer capture release - #23919

Merged
ajpinedam merged 4 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/fix.skia.itemcontainer.listview.selection
Jul 30, 2026
Merged

ajpinedam merged 4 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/fix.skia.itemcontainer.listview.selection

Conversation

@ajpinedam

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #23892

PR Type:

🐞 Bugfix

What changed? 🚀

When an ItemContainer is used as the root element of a ListView.ItemTemplate, clicking an item no longer selected it on Skia targets (regression vs 6.5.36, related to #23841).

Root cause: unlike WinUI, Uno's ItemContainer explicitly captures the pointer on press to keep its visual states accurate (#23056). On release, ReleasePointerCapture synchronously raised PointerCaptureLost, which bubbled to the hosting ListViewItem during the PointerReleased dispatch. SelectorItem subscribes to PointerCaptureLost (with handledEventsToo) to clean up scroller-canceled interactions, so it treated the click as canceled and never raised the selection.

The fix releases the Uno-internal capture with muteEvent: true in OnPointerReleased and OnPointerCanceled — this capture doesn't exist on WinUI, so no PointerCaptureLost should surface from it (same approach as Hyperlink). The scroll-steal cancellation path (CanceledByDirectManipulation) is unaffected and still aborts clicks while panning.

Validation:

  • New Given_ItemContainer runtime tests (mouse click, touch tap, touch scroll-must-not-select) fail before the fix and pass after, and assert PointerPressed/PointerReleased bubble to the ListView while no PointerCaptureLost is raised for a simple click.
  • SelectorBarTests and ItemsViewTests suites pass, guarding the previous fixes in this area (fix(selectorbar): adjust tracking of isOver mouse state #23208, fix(itemcontainer): snapshot isOver before capture release #23877).
  • New manual-test sample ItemContainer_In_ListView_ItemTemplate (ItemContainer ListView vs standard ListView side by side, with pointer diagnostics), manually validated on Skia macOS desktop.

Note: after mixed left+right mouse button presses on the same container, the pressed state can remain stale — verified this matches upstream WinUI ItemContainer.cpp behavior verbatim (parity), so it is intentionally not changed here.

PR Checklist ✅

Copilot AI review requested due to automatic review settings July 30, 2026 04:06
@github-actions github-actions Bot added the area/automation Categorizes an issue or PR as relevant to project automation label Jul 30, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a Skia regression where ListView item selection breaks when an ItemContainer is the root of the ItemTemplate, by releasing Uno’s internal pointer capture without surfacing PointerCaptureLost to ancestors during normal release/cancel flows. It adds runtime tests to prevent regressions and a SamplesApp page to manually validate pointer event behavior and selection.

Changes:

  • Release ItemContainer’s internal pointer capture using muteEvent: true in OnPointerReleased/OnPointerCanceled to avoid raising PointerCaptureLost during a normal click/tap.
  • Add new Given_ItemContainer runtime tests covering mouse click selection, touch tap selection, and touch scroll-not-select behavior.
  • Add a SamplesApp page to compare ListView behavior with/without ItemContainer and display pointer diagnostics.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/Uno.UI/UI/Xaml/Controls/ItemContainer/ItemContainer.cs Mutes pointer-capture release to avoid bubbling PointerCaptureLost to ancestor selectors during release/cancel.
src/Uno.UI.RuntimeTests/Tests/Microsoft_UI_Xaml_Controls/Given_ItemContainer.cs Adds regression tests ensuring selection works and pointer pressed/released bubble as expected when ItemContainer is used in an ItemTemplate.
src/SamplesApp/SamplesApp.Samples/Microsoft_UI_Xaml_Controls/ItemContainerTests/ItemContainer_In_ListView_ItemTemplate.xaml.cs Adds a manual validation page code-behind with selection and pointer event diagnostics.
src/SamplesApp/SamplesApp.Samples/Microsoft_UI_Xaml_Controls/ItemContainerTests/ItemContainer_In_ListView_ItemTemplate.xaml Defines the manual validation UI comparing ListView templates side-by-side.
Comments suppressed due to low confidence (1)

src/Uno.UI/UI/Xaml/Controls/ItemContainer/ItemContainer.cs:525

  • Same as in OnPointerReleased: using ReleasePointerCapture(..., muteEvent: true) will currently trigger the Info log path even when the capture was actually released, because the internal Release(...) returns false when muteEvent is set. This can produce misleading/verbose logging on every cancel path when Information logging is enabled.
		// Muted for the same reason as in OnPointerReleased: this capture doesn't exist on WinUI and
		// ancestors already receive the PointerCanceled event itself.
		ReleasePointerCapture(args.Pointer.UniqueId, muteEvent: true);

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@unodevops

Copy link
Copy Markdown
Contributor

Copilot AI review requested due to automatic review settings July 30, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.

@unodevops

Copy link
Copy Markdown
Contributor

@MartinZikmund

MartinZikmund commented Jul 30, 2026 •

Copy link
Copy Markdown
Member

@ramezgerges isn't this related to a fix you have done a while back on ItemContainer? Can you check if the behavior you added is retained please?

@mergify

mergify Bot commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@ajpinedam
ajpinedam merged commit ba8b342 into unoplatform:master Jul 30, 2026
48 checks passed
@ajpinedam
ajpinedam deleted the dev/anpi/fix.skia.itemcontainer.listview.selection branch July 30, 2026 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/automation Categorizes an issue or PR as relevant to project automation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pointer events are not raised for ListView items when ItemContainer is used inside ItemTemplate

5 participants