From 89cc851411e24d0a99c2195f20c1625e57f885d9 Mon Sep 17 00:00:00 2001 From: dreautall <109872040+dreautall@users.noreply.github.com> Date: Sat, 14 Oct 2023 19:24:33 +0000 Subject: [PATCH] Transaction: Reset Tag search when all shown tags are selected fixes #171 --- lib/pages/transaction/tags.dart | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/pages/transaction/tags.dart b/lib/pages/transaction/tags.dart index 6974503e..4e4e833e 100644 --- a/lib/pages/transaction/tags.dart +++ b/lib/pages/transaction/tags.dart @@ -265,7 +265,12 @@ class _TagDialogState extends State { ), const Divider(), ]; - for (String tag in allTags) { + final Iterable filteredTags = allTags.where( + (String t) => + _newTagTextController.text.isEmpty || + (_newTagTextController.text.isNotEmpty && + t.containsIgnoreCase(_newTagTextController.text))); + for (String tag in filteredTags) { if (_newTagTextController.text.isNotEmpty && !tag.containsIgnoreCase(_newTagTextController.text)) { continue; @@ -281,6 +286,12 @@ class _TagDialogState extends State { } else if ((selected != null && selected) && !_newSelectedTags.containsIgnoreCase(tag)) { _newSelectedTags.add(tag); + if (filteredTags + .where((String t) => + !_newSelectedTags.containsIgnoreCase(t)) + .isEmpty) { + _newTagTextController.text = ""; + } } }, );