Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjustment in initial suggestions logic #77

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/src/chips_input.dart
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,6 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
void initState() {
super.initState();
_chips.addAll(widget.initialValue);
_suggestions = widget.initialSuggestions
?.where((r) => !_chips.contains(r))
?.toList(growable: false);
// _focusAttachment = _focusNode.attach(context);
_suggestionsBoxController = SuggestionsBoxController(context);

Expand Down Expand Up @@ -165,6 +162,9 @@ class ChipsInputState<T> extends State<ChipsInput<T>>
void _handleFocusChanged() {
if (_focusNode.hasFocus) {
_openInputConnection();
_suggestions = widget.initialSuggestions
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My gut suggests that _suggestions should not repeatedly initialize from widget.initialSuggestions every time there is a focus change.

I'll need to analyze this more closely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made it this way now because the value of _suggestions was being erased after the widget lost focus and therefore the suggestionsBox only appeared without the need of keyboard input on the first time the field was focused.

But I appreciate you taking your time to look into it! If you think of another solution, please let me know.

?.where((r) => !_chips.contains(r))
?.toList(growable: false);
_suggestionsBoxController.open();
} else {
_closeInputConnectionIfNeeded();
Expand Down