diff --git a/lib/app/modules/home/controllers/home_controller.dart b/lib/app/modules/home/controllers/home_controller.dart index a7b6d353..69bf56d3 100644 --- a/lib/app/modules/home/controllers/home_controller.dart +++ b/lib/app/modules/home/controllers/home_controller.dart @@ -65,6 +65,7 @@ class HomeController extends GetxController { late RxBool serverCertExists; final Rx selectedLanguage = SupportedLanguage.english.obs; final ScrollController scrollController = ScrollController(); + final FocusNode searchFocusNode = FocusNode(); final RxBool showbtn = false.obs; late TaskDatabase taskdb; var tasks = [].obs; @@ -478,6 +479,11 @@ class HomeController extends GetxController { void toggleSearch() { searchVisible.value = !searchVisible.value; + if (searchVisible.value) { + Future.delayed(const Duration(milliseconds: 300), () { + searchFocusNode.requestFocus(); + }); + } if (!searchVisible.value) { searchedTasks.assignAll(queriedTasks); searchController.text = ''; @@ -827,4 +833,9 @@ class HomeController extends GetxController { // forReplica: taskReplica.value)); // Get.dialog(showDialog); // } + @override + void onClose() { + searchFocusNode.dispose(); + super.onClose(); + } } diff --git a/lib/app/modules/home/views/home_page_body.dart b/lib/app/modules/home/views/home_page_body.dart index a409e8ee..0e139462 100644 --- a/lib/app/modules/home/views/home_page_body.dart +++ b/lib/app/modules/home/views/home_page_body.dart @@ -43,9 +43,13 @@ class HomePageBody extends StatelessWidget { (tColors.primaryBackgroundColor!)), controller: controller.searchController, // shape:, + focusNode: controller.searchFocusNode, onChanged: (value) { controller.search(value); }, + onTapOutside: (event) { + controller.searchFocusNode.unfocus(); + }, shape: WidgetStateProperty.resolveWith( (Set states) {