Automatic unfocus when focusing the Text field
moda20 opened this issue · 2 comments
I am having a problem when trying to focus on the auto_complete textfield. when I tap the field the keyboard shows up but gets dismissed very quickly. the itemSubmittedFunction si not called here.
I do use this textfield with native flutter textFields and that sometimes causes some focus jump, where the focus starts on this field when tapped and then jumps automatically to the next field.
here is my code :
AutoCompleteTextField<Album>(
/*textChanged: (string){
this.album=string;
},*/
suggestions: this.albums,
itemBuilder: (context, currentAlbum) => new Padding(
child: new SelectableTile.mediumWithSubtitle(
subtitle: currentAlbum.artist,
imageUri: currentAlbum.albumArt,
title: currentAlbum.title,
isSelected: currentAlbum.title == this.album,
selectedBackgroundColor: MyTheme.darkRed,
placeHolderAssetUri: "images/cover.png",
onTap: (value){
albumTextField.triggerSubmitted();
},
),
padding: EdgeInsets.all(8.0)),
itemSorter: (a, b) => a?.title?.compareTo(b.title)??1>0 ? 1 : 0,
itemFilter: (suggestion, input) =>
suggestion.title.toLowerCase().startsWith(input.toLowerCase()),
style: TextStyle(
color: Colors.white,
),
decoration: InputDecoration(
hintText: this.album!=null && this.album!=""?this.album:"Add an Album title to this song",
hintStyle: TextStyle(
color: MyTheme.grey500.withOpacity(0.6)
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MyTheme.grey300.withOpacity(.7),
style: BorderStyle.solid,
width: 1
)
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: MyTheme.grey300.withOpacity(.9),
style: BorderStyle.solid,
width: 2
)
),
floatingLabelBehavior: FloatingLabelBehavior.always,
labelText: "Song Album",
labelStyle: TextStyle(
fontSize: 17,
color: MyTheme.darkRed.withOpacity(.8),
fontWeight: FontWeight.w500,
letterSpacing: 1.4,
),
),
itemSubmitted: (data) {print("submitted"); setNewAlbum(data); },
key: albumSuggestionKey,
);
Album
and SelectableTile
are my own classes.
Hi, I'm facing the same issue, did you found any solution?
Hi, I'm facing the same issue, did you found any solution?
For anyone in the future, in my case I had key: new GlobalKey()
, I replaced it with a key in the global scope GlobalKey<AutoCompleteTextFieldState<...>> key = new GlobalKey();