From fab73a0bc03e72fd0799f1a9250a868bb43f560d Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sun, 8 Feb 2026 08:01:28 +0100 Subject: [PATCH] fix: profile switcher screen focus close #415 --- lib/screens/discover_screen.dart | 6 +++++- lib/screens/profile/profile_list_tile.dart | 3 --- lib/screens/profile/profile_switch_screen.dart | 17 +++++++++++------ 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/screens/discover_screen.dart b/lib/screens/discover_screen.dart index ee31c6be..1f7da0f0 100644 --- a/lib/screens/discover_screen.dart +++ b/lib/screens/discover_screen.dart @@ -628,6 +628,11 @@ class _DiscoverScreenState extends State } }); + // Focus hero section now that it's visible, but only if no modal route is on top + if (onDeck.isNotEmpty && (ModalRoute.of(context)?.isCurrent ?? false)) { + _heroFocusNode.requestFocus(); + } + // Sync to Android TV Watch Next row if (Platform.isAndroid) { _syncWatchNext(onDeck); @@ -1244,7 +1249,6 @@ class _DiscoverScreenState extends State return SliverToBoxAdapter( child: Focus( focusNode: _heroFocusNode, - autofocus: true, onKeyEvent: _handleHeroKeyEvent, child: SizedBox( height: heroHeight, diff --git a/lib/screens/profile/profile_list_tile.dart b/lib/screens/profile/profile_list_tile.dart index fd138dfb..1e175874 100644 --- a/lib/screens/profile/profile_list_tile.dart +++ b/lib/screens/profile/profile_list_tile.dart @@ -13,7 +13,6 @@ class ProfileListTile extends StatelessWidget { final VoidCallback onTap; final bool isCurrentUser; final bool showTrailingIcon; - final bool autofocus; const ProfileListTile({ super.key, @@ -21,7 +20,6 @@ class ProfileListTile extends StatelessWidget { required this.onTap, this.isCurrentUser = false, this.showTrailingIcon = true, - this.autofocus = false, }); @override @@ -29,7 +27,6 @@ class ProfileListTile extends StatelessWidget { final theme = Theme.of(context); return ListTile( - autofocus: autofocus, leading: UserAvatarWidget(user: user, size: 40, showIndicators: false), title: Text(user.displayName), subtitle: _hasUserAttributes() ? Row(children: _buildUserAttributes(theme)) : null, diff --git a/lib/screens/profile/profile_switch_screen.dart b/lib/screens/profile/profile_switch_screen.dart index 5f1d860c..c7e35718 100644 --- a/lib/screens/profile/profile_switch_screen.dart +++ b/lib/screens/profile/profile_switch_screen.dart @@ -6,6 +6,7 @@ import '../../providers/user_profile_provider.dart'; import '../../utils/provider_extensions.dart'; import '../../utils/snackbar_helper.dart'; import 'profile_list_tile.dart'; +import '../../focus/focusable_wrapper.dart'; import '../../widgets/focused_scroll_scaffold.dart'; import '../libraries/state_messages.dart'; import '../../i18n/strings.g.dart'; @@ -78,12 +79,16 @@ class _ProfileSwitchScreenState extends State { return Padding( padding: EdgeInsets.only(left: 16, right: 16, top: index == 0 ? 16 : 0, bottom: 8), - child: Card( - child: ProfileListTile( - user: user, - isCurrentUser: isCurrentUser, - autofocus: isFirstSelectable, - onTap: () => _switchToUser(context, user), + child: FocusableWrapper( + autofocus: isFirstSelectable, + disableScale: true, + onSelect: isCurrentUser ? null : () => _switchToUser(context, user), + child: Card( + child: ProfileListTile( + user: user, + isCurrentUser: isCurrentUser, + onTap: () => _switchToUser(context, user), + ), ), ), );