Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions lib/app/modules/home/controllers/home_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class HomeController extends GetxController {
final RxBool sortHeaderVisible = false.obs;
final RxBool searchVisible = false.obs;
final TextEditingController searchController = TextEditingController();
final FocusNode searchFocusNode = FocusNode();
final StringTagController stringTagController = StringTagController();
late RxBool serverCertExists;
final Rx<SupportedLanguage> selectedLanguage = SupportedLanguage.english.obs;
Expand Down Expand Up @@ -481,6 +482,12 @@ class HomeController extends GetxController {
if (!searchVisible.value) {
searchedTasks.assignAll(queriedTasks);
searchController.text = '';
searchFocusNode.unfocus(); // Unfocus when hiding
} else {
// Request focus after the frame is built to ensure widget exists in tree
WidgetsBinding.instance.addPostFrameCallback((_) {
searchFocusNode.requestFocus();
});
}
}

Expand Down Expand Up @@ -827,4 +834,11 @@ class HomeController extends GetxController {
// forReplica: taskReplica.value));
// Get.dialog(showDialog);
// }

@override
void onClose() {
searchFocusNode.dispose();
searchController.dispose();
super.onClose();
}
}
1 change: 1 addition & 0 deletions lib/app/modules/home/views/home_page_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class HomePageBody extends StatelessWidget {
margin: const EdgeInsets.symmetric(
horizontal: 10, vertical: 10),
child: SearchBar(
focusNode: controller.searchFocusNode,
backgroundColor: WidgetStateProperty.all<Color>(
(tColors.primaryBackgroundColor!)),
surfaceTintColor: WidgetStateProperty.all<Color>(
Expand Down