TF-452 Fix search boxes should be collapsed automatically when search inputs lost focus
This commit is contained in:
@@ -117,6 +117,7 @@ class MailboxController extends BaseMailboxController {
|
||||
@override
|
||||
void onInit() {
|
||||
_initWorker();
|
||||
_registerSearchFocusListener();
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@@ -234,6 +235,17 @@ class MailboxController extends BaseMailboxController {
|
||||
});
|
||||
}
|
||||
|
||||
void _registerSearchFocusListener() {
|
||||
searchFocus.addListener(() {
|
||||
final hasFocus = searchFocus.hasFocus;
|
||||
final query = searchQuery.value.value;
|
||||
log('MailboxController::_registerSearchFocusListener(): hasFocus: $hasFocus | query: $query');
|
||||
if (!hasFocus && query.isEmpty) {
|
||||
disableSearch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void _clearWorker() {
|
||||
accountIdWorker.call();
|
||||
viewStateWorker.call();
|
||||
@@ -396,13 +408,13 @@ class MailboxController extends BaseMailboxController {
|
||||
searchState.value = searchState.value.enableSearchState();
|
||||
}
|
||||
|
||||
void disableSearch(BuildContext context) {
|
||||
void disableSearch() {
|
||||
_cancelSelectMailbox();
|
||||
listMailboxSearched.clear();
|
||||
searchState.value = searchState.value.disableSearchState();
|
||||
searchQuery.value = SearchQuery.initial();
|
||||
searchInputController.clear();
|
||||
FocusScope.of(context).unfocus();
|
||||
searchFocus.unfocus();
|
||||
}
|
||||
|
||||
void clearSearchText() {
|
||||
|
||||
Reference in New Issue
Block a user