Skip to content

fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags - #26561

Merged
MartinZikmund merged 4 commits into
masterfrom
dev/mazi/holding-dragframe-fixes
Nov 18, 2026
Merged

MartinZikmund merged 4 commits into
masterfrom
dev/mazi/holding-dragframe-fixes

Conversation

@MartinZikmund

@MartinZikmund MartinZikmund commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

GitHub Issue: closes #26560

PR Type:

🐞 Bugfix

What changed? 🚀

Two core input fixes, split out of #25389 per review so they can land (or be reverted) independently of the ListViewItemPresenter port. #25389 keeps these commits until this PR merges.

  • Holding: every element listening to Holding runs its own holding timer, and the timers can tick in any order. When an ancestor ticked first, Holding was raised from it and then again by the deepest listener (bubbling), giving a duplicate Started. The descendants' holds of the same press are now elapsed first, deepest first, so Holding is raised once and bubbles like on WinUI.
  • Drag: the one-drag-per-frame guard compared FrameId with a last value defaulting to 0, so a drag on frame 0 never started. The guard no longer swallows FrameId 0.

A runtime test covers Holding with nested listeners. The FrameId 0 drag fix has no runtime test: only the first injected pointer sequence of a process carries FrameId 0, so a test can't reliably reproduce it unless it runs first. That is also how the bug showed up, as the first touch drag of a test run silently doing nothing.

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA

Copilot AI balanced review requested due to automatic review settings November 17, 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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 31s —— View job


PR review: fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags

Verdict: fix-first (minor). The approach is sound and small. Elapsing descendants' holds first, deepest first, makes Holding fire once and bubble, as on WinUI. The nullable FrameId guard is correct.

Issues: 0 high, 2 medium (posted inline), 0 low.

Cross-cutting notes

  • Not run: this is a code-review assessment from the diff. I did not build the project or run the runtime tests.
  • Test coverage: the new runtime test covers Holding only. The FrameId 0 drag fix has no test (flagged inline).
  • Skipped test: the [Ignore] under #if !HAS_INPUT_INJECTOR follows the usual pattern for input-injector tests. It is not a deactivated test.
  • Style: tabs, braces and Conventional Commit titles look fine. The IS_UNO_UI_PROJECT guard and the use of Hold(..., timerOnlyHoldingSource) are consistent with existing helpers.
  • Hot path: GetDescendantHoldsOfSamePress uses LINQ and allocates. It returns early when fewer than two holds are pending, so this is acceptable.

@mergify

mergify Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

This pull request is merged.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/holding-dragframe-fixes branch from b1c8b87 to 9c35644 Compare November 17, 2026 14:16
Copilot AI balanced review requested due to automatic review settings November 17, 2026 14:16
@MartinZikmund
MartinZikmund changed the base branch from master to dev/mazi/contentpresenter-measure-binding November 17, 2026 14:16

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 20s —— View job


PR review: fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags

Verdict: fix-first (minor). The approach is sound and small. Elapsing descendants' holds first, deepest first, makes Holding fire once and bubble, as on WinUI. Using a nullable _lastDragStartFrameId correctly lets a drag start on FrameId 0.

Issues: 0 high, 3 medium, 0 low. The three are the two earlier inline comments (the static _pendingHolds list is not thread-safe, and the FrameId 0 drag has no test) plus a new one on StartHoldingTimer.

Cross-cutting notes

  • Code review assessment only. I did not build the project or run the runtime tests, so there is no compile or runtime validation.
  • Fix classification: the Holding change addresses the cause, since duplicate timers are now ordered. The FrameId change fixes the guard's initial-value bug.
  • Hot path: the LINQ in GetDescendantHoldsOfSamePress allocates, but it returns early when fewer than two holds are pending, so it only costs anything with nested listeners.
  • Style: tabs, braces and Conventional Commit titles look fine.

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/holding-dragframe-fixes branch from 9c35644 to 9d511f2 Compare November 17, 2026 14:53
Copilot AI balanced review requested due to automatic review settings November 17, 2026 14:53

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 11s —— View job


PR review: fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags

Verdict: ship, with one open item. The new commit fixes both threading and lifecycle concerns from the previous round. This is a code-review assessment of the diff only. I did not build or run the runtime tests, so there is no compile or runtime validation.

Resolved since the last review

  • _pendingHolds is now [ThreadStatic] and read through a lazy PendingHolds accessor, matching the per-thread timers.
  • StartHoldingTimer calls StopHoldingTimer() first, so the timer and its list entry stay one-to-one. StopHoldingTimer removes the entry only when a timer exists.
  • OnHoldingTimeElapsed stops the timer before raising. A deeper hold that elapses early therefore can't fire again from its own tick.

Still open (medium, no inline comment)

  • The FrameId 0 drag fix (uint? in UIElement.Pointers.cs) is still untested. This is a bug fix, so please add a fail-before/pass-after test. If frame 0 can't be forced with the input injector, say so in the PR description.

Minor notes

  • The [ThreadStatic] _pendingHolds field is a non-nullable List<Gesture> with no initializer. If the file is #nullable enable, declare it List<Gesture>?.
  • GetDescendantHoldsOfSamePress uses LINQ, but it exits early with fewer than two pending holds. That is fine for now.

Copilot AI balanced review requested due to automatic review settings November 17, 2026 16:22
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/holding-dragframe-fixes branch from 9d511f2 to 75f6ddf Compare November 17, 2026 16:22

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 16s —— View job


PR review: fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags

Verdict: ship. This is a review of the diff only. I did not build the project or run any tests, so there is no compile or runtime validation.

Issues: 0 high, 0 medium, 0 low. I posted no new inline comments.

Checked against the earlier review rounds

  • _pendingHolds is [ThreadStatic] and read through a lazy accessor, which matches the per-thread DispatcherQueue timers.
  • StartHoldingTimer calls StopHoldingTimer() first, and StopHoldingTimer removes the list entry only when a timer exists. The timer and its list entry stay one-to-one.
  • OnHoldingTimeElapsed stops the timer before raising Holding. A deeper hold that elapses early can't fire again from its own tick.
  • The uint? guard on _lastDragStartFrameId is correct, because x <= null is false and the first drag always starts.
  • The FrameId 0 drag has no test. The PR description explains why: only the first injected pointer sequence of a process carries FrameId 0. That is reasonable for a bug that only shows on the first drag of a process.

Minor notes (non-blocking)

  • Declare _pendingHolds as List<Gesture>? if the file is #nullable enable. The [ThreadStatic] field has no initializer, so it is null until the accessor runs.
  • GetDescendantHoldsOfSamePress uses LINQ and allocates. It exits early with fewer than two pending holds, so this is fine.
  • The changed-files list includes ContentPresenter.cs and Given_ContentPresenter.cs, which the description doesn't mention. If they only come from the base branch, ignore this.

Base automatically changed from dev/mazi/contentpresenter-measure-binding to master November 18, 2026 05:58
MartinZikmund and others added 4 commits November 18, 2026 06:58
Every element listening to Holding runs its own holding timer for the
press, and those timers can tick in any order. When an ancestor's timer
ticked first, it raised Holding from itself and the deepest listener
then raised it again, bubbling: a duplicate Started. Elapse the
descendants' holds of the same press first, deepest first, so the hold
is raised once and bubbles like on WinUI.

Exposed by ListViewBaseItem.OnHolding, which makes every ListView item
listen to Holding.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
The one-drag-per-frame guard compared the FrameId with the last one,
which defaults to 0, so a drag on frame 0 never started. The first
injected touch sequence of a process has FrameId 0, which made the
first touch drag of a test run silently do nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNu2NWgGKJFTAYtNHkvT
Holding timers tick on their own UI thread, so the pending list is
thread-static, and restarting a gesture's timer stops the previous one
so the list never holds a stale entry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01TXMNtzpwqXiaSHwvb2y5UA
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/holding-dragframe-fixes branch from 75f6ddf to 11168fd Compare November 18, 2026 05:58
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 15s —— View job


PR review: fix(gestures): Raise Holding once for nested listeners and start FrameId 0 drags

Verdict: ship. This is a review of the diff only (git diff origin/master...HEAD). I did not build the project or run any tests, so there is no compile or runtime validation.

Issues: 0 high, 0 medium, 0 low. I posted no new inline comments.

Checked on this push (HEAD 11168fde)

  • Holding, root-cause fix: descendants' pending holds of the same press now elapse first, deepest first. Holding is raised once and bubbles. OnHoldingTimeElapsed stops the timer before raising, so a deeper hold that fired early can't tick again.
  • Timer and list stay in sync: StartHoldingTimer calls StopHoldingTimer() first, and StopHoldingTimer removes the entry only when a timer exists. This resolves the earlier orphaned-timer and double-entry concern.
  • Threading: _pendingHolds is [ThreadStatic] behind a lazy accessor, matching the per-thread DispatcherQueue timers. The gesture is rooted by its timer's Tick subscription until it ticks, so the list doesn't extend its lifetime.
  • Drag FrameId 0, root-cause fix: uint? is correct, because x <= null is false and the first drag always starts. The PR description explains why there is no test: only the first injected pointer sequence of a process has FrameId 0. I accept that.
  • Test: the runtime test covers nested Holding.

Minor notes (non-blocking)

  • The [ThreadStatic] _pendingHolds has no initializer. If the file is #nullable enable, declare it List<Gesture>? to match the lazy accessor.
  • GetDescendantHoldsOfSamePress uses LINQ and allocates. It exits early with fewer than two pending holds, so it only costs anything with nested listeners.
  • Out-of-scope files: the earlier reviews noted ContentPresenter.cs and Given_ContentPresenter.cs in the changed-files list. The branch diff against origin/master touches only the four gesture and drag files, so that appears to have come from the base branch.

@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@MartinZikmund
MartinZikmund merged commit 6631330 into master Nov 18, 2026
49 of 51 checks passed
@MartinZikmund
MartinZikmund deleted the dev/mazi/holding-dragframe-fixes branch November 18, 2026 07:07
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.

Holding raised twice for nested listeners; drag ignored when pointer FrameId is 0

3 participants