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

Suggestions box falsely displayed on top of widget and not fully visible when ChipsInput is used in SingleChildScrollView #104

Open
jozes opened this issue Jan 16, 2022 · 5 comments

Comments

@jozes
Copy link

jozes commented Jan 16, 2022

When the ChipsInput widget, after getting focus by clicking in to add another chip entry, is scrolled up to became fully visible, the suggestions box is falsely displayed on top of the widget.
This situation is caused by execution of _scrollToVisible() located in the chips_input.dart which is always called on _openInputConnection().
This is not a problem when the widget position on the screen is not such that the widget could be really repositioned. But when the ChipsInput widget is displayed as one of the widgets in a SingleChildScrollView, the initial calculation of the suggestions box location is too early as the ChipsInput widget is relocated with _scrollToVisible() to be fully visible.

My solution for this problem is the following:

In function _scrollToVisible() (chips_input.dart) replace:

await Scrollable.of(context)?.position.ensureVisible(renderBox);

with

await Scrollable.of(context)?.position.ensureVisible(renderBox).then(() {
WidgetsBinding.instance?.addPostFrameCallback((
) {
_suggestionsBoxController.overlayEntry?.markNeedsBuild();
});
});

The reasoning behind is that the widget's overlay entry, which is actually the suggestions box displayed on top, needs to be rebuilt to reflect the new screen position after being scrolled and be displayed in the right position.

@jozes
Copy link
Author

jozes commented Jan 17, 2022

The above proposed solution, together with the solutions for issues #104 #102 #97 #95 is available below and hopefully it will be merged with the master some time in the future. Until then use the following in your pubspec.yaml

flutter_chips_input:
git: https://github.com/jozes/flutter_chips_input.git

@jozes jozes closed this as completed Jan 17, 2022
@jozes
Copy link
Author

jozes commented Jan 17, 2022

The above code will be thoroughly tested before I will create a pull request.

@joeatnovvia
Copy link

@jozes
I was having problems with the Samsung keyboard not allowing me to type more than 1 character.
I checked out your version of this:
flutter_chips_input:
git: https://github.com/jozes/flutter_chips_input.git

And for a Samsung keyboard, it still works a little funky: I can type more than 1 character, but when I type "jui" and then select "Juice Bar" off the list, it shows me I selected Juice Bar. And then the next thing I type makes "Juice Bar" disappear, and I see "juib" instead, as if I had just kept typing.
Have you tested your fix on Samsung phones?
Thanks!
Joe

@jozes
Copy link
Author

jozes commented Aug 9, 2022 via email

@jozes
Copy link
Author

jozes commented Aug 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants