Skip to content

test: Add ContextRequested bubbling regression tests - #23520

Merged
ajpinedam merged 3 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/context-menu-bubbling-tests
Jul 6, 2026
Merged

ajpinedam merged 3 commits into
unoplatform:masterfrom
ajpinedam:dev/anpi/context-menu-bubbling-tests

Conversation

@ajpinedam

Copy link
Copy Markdown
Contributor

GitHub Issue: closes #23440

PR Type:

🧪 Tests (regression coverage)

What changed? 🚀

Issue #23440 reports that on Skia, right-clicking a child whose ContextFlyout is set — when an ancestor also has a ContextFlyout — opens both the child's and the ancestor's context menus, because ContextRequested does not stop bubbling once a flyout is shown.

This was reproduced on the reported 6.5.36 and confirmed fixed on master using one minimal Skia-desktop app, flipping only the Uno.Sdk version in global.json and injecting a real right-click on the child:

Uno.Sdk Result
6.5.36 (reported) childOpened=1 parentOpened=1 → both menus open 🐞
6.7.0-dev.534 (master) childOpened=1 parentOpened=0 → only the child menu opens ✅

The fix is the recent context-menu rework (notably 455368f5 fix: Invoke default ContextRequested handlers during bubbling, plus 1c8aa1e1, 16645ce4, 50a0244, all 2026-01-18), which postdates the 6.5.x line and already aligns the implementation with the WinUI C++ sources. A runtime trace confirms the WinUI CControl::Delegates/FireEvent behavior:

  1. A single ContextRequested is raised from the source element. The per-element gesture-recognizer dedup (PreventEvents during the RightTapped/Holding bubble) suppresses ancestors' recognizers, so the event is raised exactly once.
  2. The class handler (OnContextRequestedCore) runs at each element up the tree during the bubble; the first element with a ContextFlyout shows it and sets Handled = true; every ancestor then bails on the Handled check.

The reported versions (6.5.31 / 6.5.36) predate this rework, which explains the discrepancy.

This PR adds regression coverage (no production code change required) that exercises the real input path (gesture recognizer → ContextRequested) across the tree shapes implied by the issue — which the existing direct-RaiseEvent tests did not cover:

  • When_RightClick_Child_Border_In_Border_Only_Child_Opens — both parent and child are non-Control elements.
  • When_RightClick_Child_Through_Intermediate_Panel_Only_Child_Opens — ancestor flyout separated by a no-flyout panel.
  • When_RightClick_ListViewItem_With_Flyout_ListView_Flyout_Not_Shown — the "file explorer" item-vs-container shape.
  • When_RightClick_Child_In_ScrollViewer_Only_Child_Opens — child inside a pointer-capturing ScrollViewer.
  • When_TouchHold_Child_In_Parent_Only_Child_Opens — touch long-press variant (mirrors linked [WASM Skia] Long press clicks before opening context menu #22229).

Each test asserts the child's flyout opens exactly once and no ancestor flyout opens. All 47 context-menu runtime tests pass on Skia Desktop.

PR Checklist ✅

Copilot AI review requested due to automatic review settings June 23, 2026 17:14

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

Adds Skia-only runtime regression tests to ensure ContextRequested bubbling stops after the first ContextFlyout is shown (preventing both child and ancestor context menus from opening), covering multiple visual-tree shapes matching issue #23440.

Changes:

  • Added input-injection-based bubbling tests for right-click and touch-hold scenarios.
  • Validated that only the innermost element’s ContextFlyout opens across Borders, panels, ListView items, and ScrollViewer cases.

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

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 219468 has failed on Uno.UI - CI.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
Copilot AI review requested due to automatic review settings June 26, 2026 14:02

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 1 out of 1 changed files in this pull request and generated 1 comment.

@unodevops

Copy link
Copy Markdown
Contributor

@unodevops

Copy link
Copy Markdown
Contributor

⚠️⚠️ The build 219943 has failed on Uno.UI - CI.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@unodevops

Copy link
Copy Markdown
Contributor

@ajpinedam
ajpinedam enabled auto-merge June 30, 2026 21:38
@ajpinedam
ajpinedam merged commit bc69c6c into unoplatform:master Jul 6, 2026
47 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Skia] Right click to open context menu does not properly stop bubbling

4 participants