Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

feat: Improve search keyboard navigation and shortcuts

Jude Cooray05658cae3113
diff --git a/mobile/apps/auth/lib/ui/code_widget.dart b/mobile/apps/auth/lib/ui/code_widget.dart
index eddeac9f32..7e03a248bf 100644
--- a/mobile/apps/auth/lib/ui/code_widget.dart
+++ b/mobile/apps/auth/lib/ui/code_widget.dart
@@ -40,6 +40,7 @@ class CodeWidget extends StatefulWidget {
final bool isReordering;
final bool enableDesktopContextActions;
final List<Code> Function()? selectedCodesBuilder;
+ final FocusNode? focusNode;
const CodeWidget(
this.code, {
@@ -49,6 +50,7 @@ class CodeWidget extends StatefulWidget {
this.isReordering = false,
this.enableDesktopContextActions = false,
this.selectedCodesBuilder,
+ this.focusNode,
});
@override
@@ -252,6 +254,7 @@ class _CodeWidgetState extends State<CodeWidget> {
child: Material(
color: Colors.transparent,
child: InkWell(
+ focusNode: widget.focusNode,
customBorder: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
diff --git a/mobile/apps/auth/lib/ui/home_page.dart b/mobile/apps/auth/lib/ui/home_page.dart
index bc11c7eaa6..fb501dab41 100644
--- a/mobile/apps/auth/lib/ui/home_page.dart
+++ b/mobile/apps/auth/lib/ui/home_page.dart
@@ -104,6 +104,7 @@ class _HomePageState extends State<HomePage> {
late CodeSortKey _codeSortKey;
final Set<LogicalKeyboardKey> _pressedKeys = <LogicalKeyboardKey>{};
+ final FocusNode _firstItemFocusNode = FocusNode();
@override
void initState() {
@@ -1023,7 +1024,7 @@ class _HomePageState extends State<HomePage> {
_pressedKeys.contains(LogicalKeyboardKey.control) ||
_pressedKeys.contains(LogicalKeyboardKey.controlRight));
- if (isMetaKeyPressed && event.logicalKey == LogicalKeyboardKey.keyF) {
+ if ((isMetaKeyPressed && event.logicalKey == LogicalKeyboardKey.keyF) || event.logicalKey == LogicalKeyboardKey.slash) {
setState(() {
_showSearchBox = true;
searchBoxFocusNode.requestFocus();
@@ -1152,6 +1153,7 @@ class _HomePageState extends State<HomePage> {
_textController.removeListener(_applyFilteringAndRefresh);
ServicesBinding.instance.keyboard.removeHandler(_handleKeyEvent);
searchBoxFocusNode.dispose();
+ _firstItemFocusNode.dispose();
super.dispose();
}
@@ -1397,6 +1399,12 @@ class _HomePageState extends State<HomePage> {
_searchText = val;
_applyFilteringAndRefresh();
},
+ onSubmitted: (_) {
+ if (_filteredCodes.isNotEmpty) {
+ // Move focus to the first item in the grid
+ _firstItemFocusNode.requestFocus();
+ }
+ },
decoration: InputDecoration(
hintText: l10n.searchHint,
border: InputBorder.none,
@@ -1785,6 +1793,7 @@ class _HomePageState extends State<HomePage> {
enableDesktopContextActions:
PlatformUtil.isDesktop(),
selectedCodesBuilder: _selectedCodesForContextMenu,
+ focusNode: index == 0 ? _firstItemFocusNode : null,
);
}),
itemCount: _filteredCodes.length,