AbdulRahmanAlHamali / flutter_typeahead

A TypeAhead widget for Flutter, where you can show suggestions to users as they type

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How can I still focus on the textfield when I set suggestion box controller close ?

SuYungCheng opened this issue · comments

Steps to reproduce

  1. I need to hide suggestion box when typing in the textfield.
  2. I use onChanged and set suggestionsBoxController.close() inside.
  3. The textfield is unfoucs.

Expected results

The textfield is still focus, but suggestion box is gone.

Actual results

The textfield unfocus and suggestion box is gone.

Package Version

4.6.2

Platform

iOS

Code sample

Code sample
suggestionsCallback: (pattern) {
                              return cardList;
                            },
...
textFieldConfiguration: TextFieldConfiguration(
                              textAlign: TextAlign.end,
                              onChanged: (value) {
                                _suggestionsBoxController.close();
                              },

Logs

Logs
[Paste your logs here]

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Hi @SuYungCheng

It seems you are using Version 4.x of the package, which is outdated. Please upgrade to the latest package version.

In Version 5.x, the SuggestionsController.close method allows passing retainFocus: true to prevent the text field from losing focus.

Additionally, the GitHub issues are not for usage questions. Please check out the links we have provided for questions.

Best regards.