Skip to content

Fix Go Back button focus obscured in ConnectedAnimation detail sample - #2212

Open
Harini Malothu (HariniMalothu17) wants to merge 1 commit into
microsoft:mainfrom
HariniMalothu17:fix/connectedanimation-focus-scroll-into-view
Open

Fix Go Back button focus obscured in ConnectedAnimation detail sample#2212
Harini Malothu (HariniMalothu17) wants to merge 1 commit into
microsoft:mainfrom
HariniMalothu17:fix/connectedanimation-focus-scroll-into-view

Conversation

@HariniMalothu17

@HariniMalothu17 Harini Malothu (HariniMalothu17) commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

On the ConnectedAnimation page, keyboard focus can be obscured in the "connected animation between a list page and a detail page" sample. The sample is hosted in a fixed-height Frame inside the gallery page's ScrollViewer.

After navigating in from a lower list item, the detail page's Go Back button receives focus but lands outside the page's viewport, so keyboard focus is on a control the user cannot see (MAS 2.4.11 - Focus Not Obscured).

Fix

Call GoBackButton.StartBringIntoView() right after focusing it, so the page-level ScrollViewer scrolls the focused button into view. The displayed sample code snippet is updated to match.

Repro (before fix)

  1. Open ConnectedAnimation (most obvious when the window is not full-height).
  2. In the list under "A connected animation between a list page and a detail page", focus a lower item with the keyboard and press Enter.
  3. On the detail page the Go Back button is focused but scrolled off-screen / not visible.

After the fix, the page scrolls so the focused Go Back button is visible.

Testing

  • Built WinUIGallery (Debug/x64) -> 0 errors.
  • Verified via UI Automation that, before the fix, the focused Go Back button reports IsOffscreen = True after navigation.
Recording.2026-08-07.151617.mp4

@HariniMalothu17
Harini Malothu (HariniMalothu17) force-pushed the fix/connectedanimation-focus-scroll-into-view branch 2 times, most recently from 4679197 to 0349db0 Compare August 7, 2026 09:57
On the ConnectedAnimation page, the list/detail sample is hosted in a
fixed-height Frame inside the gallery page's ScrollViewer. After
navigating from a lower list item into the detail page, the "Go Back"
button receives focus but lands outside the page's viewport, so keyboard
focus is on a control the user cannot see (MAS 2.4.11 - Focus Not
Obscured).

Call GoBackButton.StartBringIntoView() after focusing it so the outer
page scroll viewer scrolls the focused button into view. The displayed
sample code snippet is updated to match.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 2620f9d2-ff0f-45b0-aa36-3626abe3e83a
@HariniMalothu17
Harini Malothu (HariniMalothu17) force-pushed the fix/connectedanimation-focus-scroll-into-view branch from 0349db0 to 72e74db Compare August 7, 2026 09:59
@HariniMalothu17 Harini Malothu (HariniMalothu17) changed the title Fix keyboard focus obscured in ConnectedAnimation list/detail sample Fix Go Back button focus obscured in ConnectedAnimation detail sample Aug 7, 2026

// Scroll the back button into view so keyboard focus is not left off-screen behind
// the surrounding scroll viewer (MAS 2.4.11 - Focus Not Obscured).
GoBackButton.StartBringIntoView();

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.

Is this something scroller should do internally when something in it gets focused?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Good question. A ScrollViewer does bring the focused element into view automatically, but only when focus moves via keyboard navigation (Tab / arrow keys) - in that case the input system raises the bring-into-view request for you.

Here the Go Back button is focused programmatically in GoBackButton_Loaded (Focus(FocusState.Programmatic)) so a keyboard user can immediately activate it on landing. Programmatic focus does not trigger that automatic scroll, so with the fixed-height frame still scrolled to where the list item was, the button can remain off-screen. The explicit StartBringIntoView() covers that programmatic-focus case.

(If we instead focused it with FocusState.Keyboard, the scroller would handle it on its own - I kept the explicit call so the focus-visual behavior stays unchanged, but happy to switch to keyboard focus if you'd prefer to lean on the built-in behavior.)

@HariniMalothu17

Copy link
Copy Markdown
Collaborator Author

/azp run

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM

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.

3 participants