Skip to content

feat(scrollviewer): Animate keyboard scrolling - #24741

Draft
MartinZikmund wants to merge 8 commits into
masterfrom
dev/mazi/scroll-keyboard-animation
Draft

MartinZikmund wants to merge 8 commits into
masterfrom
dev/mazi/scroll-keyboard-animation

Conversation

@MartinZikmund

Copy link
Copy Markdown
Member

GitHub Issue: closes #24734

Stacked PR 7/7. Base: dev/mazi/scroll-wheel-winui-curve. Review only this PR's commits; it merges after the PRs below it.

PR Type:

✨ Feature

What changed? 🚀

Keyboard scrolling teleported (~32 new frames/s under key auto-repeat). Now:

  • Arrow keys glide along the wheel curve; each press adds to the glide in flight, so auto-repeat is one continuous motion that lands exactly on the target.
  • PageUp/PageDown/Home/End animate like ChangeView (same easing and distance-scaled duration).
  • Handled/focus semantics unchanged. ListView keyboard focus navigation stays unanimated, matching WinUI (it animates only gamepad/navigation keys).

Evidence (Win32 119 Hz): key-down newFps 32 → 120, judder 0.24–0.27 px; page-down 120, 0.4 px; no backward steps.

Tests (Runtime): consecutive key presses produce one continuous glide with a single final ViewChanged (fails before: one per press); existing keyboard tests wait for the animation.

Measured with the scroll-smoothness probe from #24711 (sample=Scrolling/ScrollSmoothnessTester&scrollprobe=...). newFps = presented frames showing a newly recorded frame per second; judder = RMS residual of the offset against a local quadratic through neighbouring presented frames.

Full runtime suite (Skia Win32, 150% scale): no new failures versus master; the remaining failures are pre-existing (ListViewBase ×6, ScrollPresenterTests ×3 at fractional scale).

PR Checklist ✅

🤖 Generated with Claude Code

https://claude.ai/code/session_016WqaiNE2QBeUszQFongehx

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 7s —— View job


Review complete ✅

Todo list:

  • Gather context (PR body, diff vs origin/dev/mazi/scroll-wheel-winui-curve)
  • Understand the request (review against AGENTS.md rules)
  • Review ScrollViewer.cs changes
  • Review ScrollContentPresenter.cs / ScrollContentPresenter.Managed.cs changes
  • Review runtime test changes
  • Post inline findings
  • Post summary

Verdict: Ship with minor fixes

The keyboard-glide implementation is a small, well-targeted change (GlideForKeyboard → Presenter.GlideTo/AddWheelImpulse), reuses the wheel-motion machinery from earlier PRs in this stack instead of duplicating it, and the retargeting logic (GlideTo folding a new key press into the glide already in flight) is sound. The page/extent-key path correctly reuses the existing animated ChangeView. Handled/focus semantics are unchanged from before this PR.

Findings (2, both Medium/Low severity)

  1. Test discovery — the new runtime test wraps the entire [TestMethod] in #if __SKIA__, which the repo's own .claude/rules/runtime-tests.md explicitly calls out as breaking test discovery (should be [PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.NativeWinUI)] instead). Note this mirrors two pre-existing tests already in this file, so it's propagating an existing pattern rather than introducing a new one.
  2. Consistency/robustness — GlideTo's early-out uses exact == on doubles instead of NumericExtensions.AreClose, which is used everywhere else in the same class for offset comparisons; a float-precision mismatch here just causes a harmless but unnecessary wheel-motion restart, not a wrong landing offset.

Cross-cutting notes (not blocking)

  • I verified the fallback branch in GlideTo (landing directly when there's no frame driver) passes the un-clamped horizontalOffset/verticalOffset to Set(...) rather than the clamped targetH/targetV — this looked like a bug at first glance, but Set() re-clamps internally via ValidateInputOffset, so it's not an actual issue.
  • No async/cancellation, DependencyProperty, XAML, or event-declaration concerns — this PR doesn't touch those surfaces.
  • Commit messages follow Conventional Commits.

Branch: dev/mazi/scroll-keyboard-animation

@github-actions

github-actions Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 36s —— View job


Review complete ✅

Todo list:

  • Gather context (diff vs origin/dev/mazi/scroll-wheel-winui-curve)
  • Review ScrollViewer.cs changes
  • Review ScrollContentPresenter.cs / ScrollContentPresenter.Managed.cs changes
  • Review runtime test changes
  • Post inline findings
  • Post summary

Verdict: Ship with minor fixes

Independently re-verified this diff against origin/dev/mazi/scroll-wheel-winui-curve. The keyboard-glide design holds up: GlideForKeyboard correctly forks Page/Home/End (routed through the existing animated ChangeView) from arrow keys (routed through the new ScrollContentPresenter.GlideTo), GlideTo reuses AddWheelImpulse's room-check/frame-driver bootstrap rather than duplicating it, and the TargetHorizontalOffset/TargetVerticalOffset getters now correctly reporting the in-flight glide's projected end (not the stale displayed offset) is what makes Handled and repeated-press retargeting work. args.Handled semantics and focus-navigation bubbling in OnKeyDown are untouched by this diff.

Findings (2)

Both Low/Medium severity, posted inline:

  1. Test discovery (Given_ScrollViewer.cs:448-501) — the new When_Keys_Pressed_In_A_Row_Then_Glides_Continuously wraps its [TestMethod] in #if __SKIA__, which per .claude/rules/runtime-tests.md breaks discovery on non-Skia builds instead of showing as skipped. The file already has the correct pattern ([PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.NativeWinUI)]) in several other tests.
  2. Floating-point equality (ScrollContentPresenter.Managed.cs:757) — GlideTo's early-out uses exact == on the clamped target vs. TargetHorizontalOffset/TargetVerticalOffset, while the rest of the class uses NumericExtensions.AreClose(...) for the same kind of comparison. Worst case is a spurious wheel-motion restart for a zero-distance glide, not a wrong landing offset.

Note: both of these were already surfaced by earlier automated review passes on this PR and don't appear to have been addressed yet in the current HEAD (fe158f45) — re-flagging since they're still present in the diff under review.

Cross-cutting notes (not blocking)

  • Traced through GlideTo's fallback branch (Set(...) with unclamped horizontalOffset/verticalOffset when AddWheelImpulse returns false) — confirmed non-issue, Set() re-clamps internally via ValidateInputOffset.
  • GlideTo calls AddWheelImpulse (which internally retargets via AddDistance/MoveTargetTo) and then immediately overwrites the target again via an explicit MoveTargetTo(targetH/V). This double-retarget is intentional per the inline comment (avoids compounding float error across repeated add/subtract), and harmless since no frame tick occurs between the two calls — not filed as a finding.
  • No DependencyProperty, XAML, async/cancellation, or event-declaration (EventHandler vs Action) concerns — this PR doesn't touch those surfaces.
  • Commit messages follow Conventional Commits.
    · Branch: dev/mazi/scroll-keyboard-animation

Copilot AI balanced review requested due to automatic review settings October 2, 2026 05: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 review overview

🟡 Changes recommended

Keyboard animation handoffs can ignore keys or visibly jump, and the new test lacks cleanup.

Review effort: Balanced
Findings: 2 Medium severity · 1 Low severity

Open (3)
What changed in this PR

Adds animated keyboard scrolling to ScrollViewer, including continuous arrow-key gliding and animated page/extent navigation.

Changes:

  • Adds keyboard-specific glide behavior.
  • Tracks in-flight wheel-motion targets.
  • Updates and extends runtime tests.
File Description
ScrollViewer.cs Routes keyboard scrolling through animations.
ScrollContentPresenter.Managed.cs Adds glide retargeting.
ScrollContentPresenter.cs Exposes projected motion targets.
Given_ScrollViewer.cs Updates and adds keyboard tests.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Copilot AI balanced review requested due to automatic review settings October 3, 2026 09:43
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-keyboard-animation branch from 1d603ae to 9efc4a9 Compare October 3, 2026 09:43

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 1 High severity · 5 Medium severity · 1 Low severity

Open (7)

Copilot AI balanced review requested due to automatic review settings October 3, 2026 09:59

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.

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 5m 5s —— View job


Review complete ✅

Todo list:

  • Gather context (diff vs origin/dev/mazi/scroll-wheel-winui-curve)
  • Review ScrollViewer.cs changes
  • Review ScrollContentPresenter.cs / ScrollContentPresenter.Managed.cs changes
  • Review runtime test changes
  • Post inline findings
  • Post summary

Verdict: Fix-first

Independently re-traced the diff against origin/dev/mazi/scroll-wheel-winui-curve. The two previously-flagged issues (#if __SKIA__ wrapping [TestMethod], and == vs AreClose in GlideTo) are confirmed fixed at HEAD (9efc4a92/033c2d1f). Three issues from the earlier Copilot pass are still unaddressed in the current diff — I independently re-derived and confirmed all three by tracing the actual code paths rather than taking them at face value, and they're posted as inline comments:

Findings (3)

  1. ScrollViewer.cs:1345 (Medium/High) — GlideForKeyboard routes Page/Home/End through the public ChangeView(...), whose own no-op guard (line 1471-1472) compares the requested offset against the stale VerticalOffset/HorizontalOffset getters rather than Presenter.TargetVerticalOffset/TargetHorizontalOffset. Since arrow-key gliding no longer updates those offsets synchronously (only on the next composition-frame tick), a Home/End/Page key pressed immediately after an arrow key can hit ChangeView's no-op path and return without ever calling Presenter.Set()/StopWheelMotion() — the in-flight arrow-key glide then keeps running, landing away from the requested Home/End/Page target. Traced a concrete repro: Down then immediate Home from offset 0 lands at ~26 instead of 0. args.Handled is also wrong for Home/End in this case (stays false, unlike Page keys which are force-set at line 1813).
  2. ScrollContentPresenter.Managed.cs:762 (Medium) — GlideTo/AddWheelImpulse seed the new wheel-motion curve from HorizontalOffset/VerticalOffset, which Set() already writes to the final destination synchronously even while an animated ChangeView (Page/Home/End) is still mid-flight on its composition animation. An arrow key pressed during that animation starts the glide from the old animation's destination, whose first frame tick stops the running AnchorPoint animation (snapping the view forward) and publishes a premature non-intermediate ViewChanged via OnStopped.
  3. Given_ScrollViewer.cs:493 (Low) — the new When_Keys_Pressed_In_A_Row_Then_Glides_Continuously test never resets WindowHelper.WindowContent in its finally, per the documented convention in .claude/rules/runtime-tests.md and the pattern used elsewhere in this same file.

Cross-cutting notes (not separately filed)

  • Findings 1 and 2 share a root cause: TargetHorizontalOffset/TargetVerticalOffset (new in this PR) only account for an in-flight wheel-motion glide, not for an in-flight animated ChangeView — the two new offset-tracking mechanisms this PR introduces don't yet know about each other.
  • Neither interaction is exercised by the new or updated tests: When_Keys_Pressed_In_A_Row_Then_Glides_Continuously only repeats Down, and When_Home_End_PageDown_PageUp/When_Args_Handled_... wait for each animation to fully settle before the next key, so a key pressed mid-glide is never tested.
  • No DependencyProperty, XAML, async/cancellation, or event-declaration (EventHandler vs Action) concerns — this PR doesn't touch those surfaces. Commit messages follow Conventional Commits.
    · Branch: dev/mazi/scroll-keyboard-animation

@github-actions

github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @MartinZikmund's task in 4m 23s —— View job


Review complete ✅

Todo list:

  • Gather context (diff vs origin/dev/mazi/scroll-wheel-winui-curve)
  • Review ScrollViewer.cs changes
  • Review ScrollContentPresenter.cs / ScrollContentPresenter.Managed.cs changes
  • Review runtime test changes
  • Check status of previously-raised findings (AreClose fix, #if __SKIA__ fix, Copilot findings)
  • Post inline findings
  • Post summary

Verdict: Fix before merge

The two previously-flagged nits are confirmed fixed at this HEAD: GlideTo's early-out now uses NumericExtensions.AreClose (ScrollContentPresenter.Managed.cs:757), and When_Keys_Pressed_In_A_Row_Then_Glides_Continuously now uses [PlatformCondition(ConditionMode.Exclude, RuntimeTestPlatforms.NativeWinUI)] instead of wrapping [TestMethod] in #if __SKIA__.

However, tracing through the interaction between the new glide/ChangeView paths surfaced 2 confirmed functional bugs (both corroborate unresolved findings from the Copilot review pass, traced here to root cause with a concrete repro) plus 1 test-hygiene issue, posted inline:

  1. ScrollViewer.cs:1345 (Medium/High) — Page/Home/End can be silently dropped, or land at the wrong offset, when an arrow-key glide is already in flight. ChangeView's change-detection compares the request against the raw VerticalOffset/HorizontalOffset DP, which only updates once a wheel-motion frame has ticked — not against Presenter.TargetVerticalOffset/TargetHorizontalOffset (the getters this PR added precisely to report "where a glide comes to rest"). Concrete repro: from offset 0, press Down (starts a glide, no frame ticked yet) then immediately Home — ChangeView(0, 0, …) sees "no change" against the still-stale VerticalOffset == 0, returns early without calling Set()/StopWheelMotion(), and the Down glide runs to completion while Home is dropped (and args.Handled for Home also comes back false).
  2. ScrollContentPresenter.Managed.cs:762 (Medium) — An arrow-key glide started while a Page/Home/End animated ChangeView is still visually in flight seeds AddWheelImpulse from HorizontalOffset/VerticalOffset, which already hold the animation's destination (set synchronously in Set()), not the actually-rendered position. The next wheel-motion frame then snaps the visual straight to that destination before continuing the glide — a visible jump.
  3. Given_ScrollViewer.cs:490-492 (Low) — the new test's finally block unsubscribes the Rendering handler but never resets WindowHelper.WindowContent, contrary to .claude/rules/runtime-tests.md's "always reset shared state in finally" rule; low cost to fix since the try/finally is already in place.

Cross-cutting notes (not blocking)

  • ScrollViewer.cs:1768-1810's use of Presenter.TargetHorizontalOffset/TargetVerticalOffset (rather than the raw DP) for computing newOffset and args.Handled for arrow keys is correct — the inconsistency is specifically that the Page/Home/End path falls back to the public ChangeView, which doesn't get the same treatment.
  • No DependencyProperty, XAML, async/cancellation, or event-declaration (EventHandler vs Action) concerns — this PR doesn't touch those surfaces.
  • Commit messages follow Conventional Commits.

Branch: dev/mazi/scroll-keyboard-animation

@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-keyboard-animation branch from fc611c9 to d623ecb Compare October 8, 2026 15:26
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-keyboard-animation branch 3 times, most recently from d31bb38 to bc553b9 Compare October 8, 2026 21:32
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-keyboard-animation branch from bc553b9 to dbc5d68 Compare October 10, 2026 15:29
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-keyboard-animation branch 2 times, most recently from 43f22d7 to 07d4ce5 Compare October 12, 2026 21:44
Base automatically changed from dev/mazi/scroll-wheel-winui-curve to master October 13, 2026 12:22
MartinZikmund and others added 8 commits October 13, 2026 14:22
Arrow, Page, Home and End keys teleported the offset. WinUI animates them
(through DManip), so glide instead, on the same curve as the wheel: each
press retargets the glide in flight, so a held key's auto-repeat keeps
one motion, and the next press is measured from where the glide will
rest. The glide lands exactly on the requested offset. Snap points and
the offset intent are applied as for ChangeView, and the handled/focus
logic is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016WqaiNE2QBeUszQFongehx
The existing keyboard tests now wait for the glide to settle before
reading the offset.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016WqaiNE2QBeUszQFongehx
Page Up/Down, Home and End now animate like an animated ChangeView, with
ScrollPresenter's easing and distance-scaled duration, instead of on the
wheel's decay. Arrows keep the decay glide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016WqaiNE2QBeUszQFongehx
@MartinZikmund
MartinZikmund force-pushed the dev/mazi/scroll-keyboard-animation branch from 07d4ce5 to a659c1e Compare October 13, 2026 12:22
@unodevops

Copy link
Copy Markdown
Contributor

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 239163 found UI Test snapshots differences: skia-linux-screenshots: 118, skia-windows-screenshots: 2458

Details
  • skia-linux-screenshots: 118 changed over 2458

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • ClipboardTests.png-dark
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • CompositionEffectBrush.png-dark
    • CompositionEffectBrush.png
    • CompositionNineGridBrush_Source_Changes.png-dark
    • CompositionNineGridBrush_Source_Changes.png
    • ElementLevelTheme.png-dark
    • ElementLevelTheme.png
    • DynamicFont.png-dark
    • DisplayInformation.png-dark
    • DynamicFont.png
    • DoubleImageBrushInList.png-dark
    • DoubleImageBrushInList.png
    • Examples.png
    • ImageIconPage.png-dark
  • skia-windows-screenshots: 2458 changed over 2488

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AndroidWindowInsets.png
    • AnimatedVisualsTestbedPage.png-dark
    • Application_DispatcherShutdownMode.png-dark
    • AppXamlDefinedResources.png-dark
    • Attributed_text_Simple.png
    • AutoBorderStretchwithbottommargin.png
    • AutomationProperties_AutomationId.png-dark
    • AutomationProperties_StructureAndProps.png
    • AutoSuggestBox_Description.png-dark
    • AutoSuggestBox_Description.png
    • Basics Pivot Test.png-dark
    • Basics Pivot Test.png
    • BeginTime_MultipleAnimations.png-dark
    • BeginTime_MultipleAnimations.png
    • BitmapIcon_Monochromatic.png-dark
    • BitmapIcon_Monochromatic.png
    • BorderCenteredwithmargins.png-dark
    • BorderCenteredwithmargins.png
    • BorderRightwithmargins.png-dark
    • BorderRightwithmargins.png

@unodevops

Copy link
Copy Markdown
Contributor

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

@MartinZikmund MartinZikmund added the 7.1 PRs only. For issues, use the Release field. label Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

7.1 PRs only. For issues, use the Release field.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keyboard scrolling in ScrollViewer jumps instead of animating

6 participants