Fix Go Back button focus obscured in ConnectedAnimation detail sample - #2212
Conversation
4679197 to
0349db0
Compare
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
0349db0 to
72e74db
Compare
|
|
||
| // 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(); |
There was a problem hiding this comment.
Is this something scroller should do internally when something in it gets focused?
There was a problem hiding this comment.
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.)
|
/azp run |
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
Frameinside the gallery page'sScrollViewer.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-levelScrollViewerscrolls the focused button into view. The displayed sample code snippet is updated to match.Repro (before fix)
After the fix, the page scrolls so the focused Go Back button is visible.
Testing
WinUIGallery(Debug/x64) -> 0 errors.Go Backbutton reportsIsOffscreen = Trueafter navigation.Recording.2026-08-07.151617.mp4