feat(tv): scroll focused scrollbar into view - #2338
Open
usmanvrtx wants to merge 2 commits into
Open
Conversation
Add TV scroll-into-view logic that reveals the focused scrollbar within its nearest vertical scrollable ancestor. Only affects vertical scrolling so horizontal navigation doesn't jitter.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR ensures a focused scrollbar is always revealed within its enclosing vertical scrollable on TV. Previously, when the scrollbar gained focus while positioned outside the visible viewport of a parent scrollable (e.g. a long ListView), it could remain hidden off-screen, making D-pad navigation confusing.
The change adds a reusable scroll-into-view helper that scrolls only the nearest vertical scrollable ancestor, so vertical positioning is fixed without jittering horizontal navigation.
Related Issue
N/A
Type of Change
What Has Changed
modules/ensemble/lib/framework/tv/tv_focus_scroll.dartwith:findNearestVerticalScrollable(BuildContext)— finds the nearest verticalScrollableancestorscrollWidgetIntoView(BuildContext, {verticalPadding, animationDurationMs, curve})— scrolls only the nearest vertical scrollable so a widget's render box is fully visible, using padding from the viewport edges and clamping to valid scroll extentskTVScrollAnimationDurationMs,kTVVerticalScrollPadding,kTVScrollThresholdTVScrollbarWidgetintv_scrollbar_widget.dartto callscrollWidgetIntoView(context)when the scrollbar gains focus, via a post-frame callback that re-checks_isFocusedso stale callbacks are ignoredbox_wrapper.dartHow to Test
flutter test modules/ensemble/test/widget/tv_scrollbar_widget_test.dartScreenshots / Videos
N/A
Checklist
flutter analyzeand addressed any new warningsflutter testand all tests pass