diff --git a/lib/app/views/device_picker_dialog.dart b/lib/app/views/device_picker_dialog.dart index 27bcb78b..6ec53689 100755 --- a/lib/app/views/device_picker_dialog.dart +++ b/lib/app/views/device_picker_dialog.dart @@ -40,9 +40,48 @@ class _HiddenDevicesNotifier extends StateNotifier> { } } -class DevicePickerDialog extends ConsumerWidget { +class DevicePickerDialog extends StatefulWidget { const DevicePickerDialog({super.key}); + @override + State createState() => _DevicePickerDialogState(); +} + +class _DevicePickerDialogState extends State { + late FocusScopeNode _focus; + + @override + void initState() { + super.initState(); + _focus = FocusScopeNode(); + } + + @override + void dispose() { + _focus.dispose(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + // This keeps the focus in the dialog, even if the underlying page + // changes as it does when a new device is selected. + return FocusScope( + node: _focus, + autofocus: true, + onFocusChange: (focused) { + if (!focused) { + _focus.requestFocus(); + } + }, + child: const _DevicePickerContent(), + ); + } +} + +class _DevicePickerContent extends ConsumerWidget { + const _DevicePickerContent(); + @override Widget build(BuildContext context, WidgetRef ref) { final hidden = ref.watch(_hiddenDevicesProvider);