Skip to content

Feat/tabbar focus onback - #2389

Merged
usmanvrtx merged 2 commits into
android_TV_implementationfrom
feat/tabbar-focus-onback
Oct 16, 2026
Merged

usmanvrtx merged 2 commits into
android_TV_implementationfrom
feat/tabbar-focus-onback

Conversation

@usmanvrtx

Copy link
Copy Markdown
Member

Description

Adds an opt-in TV behavior for TabBar: when focus is inside tab content, the first Back press returns focus to the selected tab instead of leaving the screen. A separate Back press then follows the existing navigation behavior. The option defaults to false, so existing behavior is unchanged.

Related Issue

N/A

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

  • Added the styles.tabFocusOnBack option to TabBar; it is opt-in and defaults to false.
  • When enabled on TV, Back from tab content focuses the selected tab, reveals the tab strip if needed, and consumes the associated key repeats and release.
  • Kept the behavior scoped to TabBar content; TabBarOnly and ScrollableTabBar are unchanged.
  • Added widget tests for selected-tab focus, key event handling, scrolled-away strips, indexed content, runtime tab changes, hidden tabs, non-TV behavior, and expanded layout.
  • Documented the option in the layout widgets guide.

How to Test

From modules/ensemble, run:

flutter test test/widget/tab_bar_back_focus_test.dart

On a TV device or emulator, enable styles.tabFocusOnBack: true on a TabBar. Focus an item inside the selected tab and press Back: focus should return to the selected tab without leaving the screen. Press Back again to confirm normal navigation behavior.

Screenshots / Videos

Not applicable.

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors

@usmanvrtx usmanvrtx self-assigned this Oct 16, 2026
@usmanvrtx
usmanvrtx changed the base branch from main to android_TV_implementation October 16, 2026 02:55
@usmanvrtx
usmanvrtx merged commit 9d6214a into android_TV_implementation Oct 16, 2026
6 checks passed
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.

2 participants