fix(jellyfin): preserve add screen dpad focus
This commit is contained in:
@@ -138,19 +138,11 @@ class _AddJellyfinScreenState extends State<AddJellyfinScreen> with AsyncFormSta
|
||||
? await factory()
|
||||
: await JellyfinLanDiscoveryService().discover(responseWindow: const Duration(milliseconds: 1300));
|
||||
if (!mounted || attemptId != _localDiscoveryAttemptId) return;
|
||||
final focusFirstServer =
|
||||
servers.isNotEmpty && _urlController.text.trim().isEmpty && _serverInfo == null && PlatformDetector.isTV();
|
||||
setState(() {
|
||||
_localServers = servers;
|
||||
_isDiscoveringLocalServers = false;
|
||||
_syncDiscoveredServerFocusNodes(servers);
|
||||
});
|
||||
if (focusFirstServer) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (!mounted) return;
|
||||
_discoveredServerFocusNodes[servers.first.id]?.requestFocus();
|
||||
});
|
||||
}
|
||||
} catch (e, st) {
|
||||
appLogger.w('Add Jellyfin local discovery failed', error: e, stackTrace: st);
|
||||
if (!mounted || attemptId != _localDiscoveryAttemptId) return;
|
||||
@@ -743,7 +735,7 @@ class _DiscoveredJellyfinServerTile extends StatelessWidget {
|
||||
focusNode: focusNode,
|
||||
disableScale: true,
|
||||
borderRadius: 12,
|
||||
useBackgroundFocus: true,
|
||||
useForegroundFocusDecoration: true,
|
||||
descendantsAreFocusable: false,
|
||||
onSelect: onTap,
|
||||
onNavigateUp: onNavigateUp,
|
||||
|
||||
@@ -117,6 +117,41 @@ void main() {
|
||||
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Url');
|
||||
});
|
||||
|
||||
testWidgets('TV discovery does not steal focus from the URL keyboard', (tester) async {
|
||||
TvDetectionService.debugSetAppleTVOverride(true);
|
||||
|
||||
await tester.pumpWidget(
|
||||
InputModeTracker(
|
||||
child: MaterialApp(
|
||||
home: AddJellyfinScreen(
|
||||
localDiscoveryFactory: () async => [
|
||||
DiscoveredJellyfinServer(address: 'http://192.168.1.20:8096', id: 'srv-1', name: 'Home'),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Home'), findsOneWidget);
|
||||
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
|
||||
await tester.pump();
|
||||
|
||||
expect(FocusManager.instance.primaryFocus?.debugLabel, 'TvVirtualKeyboard');
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.gameButtonB);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Url');
|
||||
|
||||
await tester.sendKeyEvent(LogicalKeyboardKey.arrowDown);
|
||||
await tester.pump();
|
||||
|
||||
expect(FocusManager.instance.primaryFocus?.debugLabel, 'AddJellyfin:Discovered:srv-1');
|
||||
});
|
||||
|
||||
testWidgets('D-pad moves from URL to credentials after server is found', (tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
|
||||
Reference in New Issue
Block a user