From cd7b01a73628c62fe423fb25b2e8361b254747f5 Mon Sep 17 00:00:00 2001 From: rustdesk Date: Wed, 21 Oct 2026 13:55:16 +0800 Subject: [PATCH] fix(file-transfer): keep default keys on focused file list children The navigation bindings wrapped the whole file list, sort headers included, so a header focused with Tab lost Enter to sort and the arrow keys to move between headers: Enter ran the open-folder binding instead. Handle the bindings only while the list itself has primary focus and let keys on a focused child take their default path. Co-Authored-By: Claude Opus 5.5 --- .../lib/desktop/pages/file_manager_page.dart | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/flutter/lib/desktop/pages/file_manager_page.dart b/flutter/lib/desktop/pages/file_manager_page.dart index 58d53a5c5..213136145 100644 --- a/flutter/lib/desktop/pages/file_manager_page.dart +++ b/flutter/lib/desktop/pages/file_manager_page.dart @@ -497,8 +497,10 @@ class _FileManagerViewState extends State { }, onExit: (evt) => widget._mouseFocusScope.value = MouseFocusScope.none, - child: CallbackShortcuts( - bindings: _fileListKeyBindings(), + child: Focus( + canRequestFocus: false, + skipTraversal: true, + onKeyEvent: _onFileListKeyEvent, child: _buildFileList(context, _fileListScrollController), ), )) @@ -1366,6 +1368,19 @@ class _FileManagerViewState extends State { debugPrint("focused on ${searchResult.first.name}"); } + KeyEventResult _onFileListKeyEvent(FocusNode node, KeyEvent event) { + // A focused child such as a sort header keeps its default keys, e.g. + // Enter to sort. + if (!_keyboardNode.hasPrimaryFocus) return KeyEventResult.ignored; + for (final binding in _fileListKeyBindings().entries) { + if (binding.key.accepts(event, HardwareKeyboard.instance)) { + binding.value(); + return KeyEventResult.handled; + } + } + return KeyEventResult.ignored; + } + Map _fileListKeyBindings() { int all() => controller.directory.value.entries.length; return {