TF-4011 Support arrow keys on keyboard to get again focus after deleting a recipient

This commit is contained in:
dab246
2025-09-11 16:43:23 +07:00
committed by Dat H. Pham
parent 9abde49c62
commit cf40d22cc8
8 changed files with 51 additions and 55 deletions
@@ -67,7 +67,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
late List<EmailAddress> listEmailAddress;
bool lastTagFocused = false;
int _tagIndexFocused = -1;
@override
void initState() {
@@ -107,15 +107,17 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
suggestionsBoxBackgroundColor: Colors.white,
suggestionsBoxRadius: 16,
suggestionsBoxMaxHeight: 350,
onFocusTagAction: (focused) {
onFocusTagAction: (index) {
setState(() {
lastTagFocused = focused;
_tagIndexFocused = index;
});
},
onDeleteTagAction: () {
if (listEmailAddress.isNotEmpty) {
onDeleteTagAction: (index) {
if (listEmailAddress.isNotEmpty &&
index >= 0 &&
index < listEmailAddress.length) {
setState(() {
listEmailAddress.removeLast();
listEmailAddress.removeAt(index);
});
}
},
@@ -136,8 +138,7 @@ class _AutocompleteContactTextFieldWithTagsState extends State<AutocompleteConta
),
tagBuilder: (context, index) => ContactInputTagItem(
listEmailAddress[index],
isLastContact: index == listEmailAddress.length - 1,
lastTagFocused: lastTagFocused,
isTagFocused: _tagIndexFocused == index,
deleteContactCallbackAction: (contact) {
setState(() => listEmailAddress.remove(contact));
}