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

Fix for auto scroll issue #180

Merged
merged 4 commits into from
Jan 2, 2024
Merged

Fix for auto scroll issue #180

merged 4 commits into from
Jan 2, 2024

Conversation

starfreck
Copy link
Contributor

@starfreck starfreck commented Dec 20, 2023

closes: #179

Usage Example:

Create a new ScrollController and pass it to TextField and EmojiPicker :

final scrollController = ScrollController();
...
TextField(
    minLines: 1,
    maxLines: 4, // Auto scrolling should work after 4th line
    focusNode: focusNode,
    controller: textEditingController,
    scrollController: scrollController,
    decoration: const InputDecoration(
        hintText: "Message",
        border: InputBorder.none,
    ),
),
...
EmojiPicker(
    textEditingController: textEditingController,
    scrollController: scrollController,
    onBackspacePressed: () {},
    ....
    ),
),

Reference: https://stackoverflow.com/questions/71408717/flutter-textfield-content-does-not-scroll-automatically-when-inserting-text

@starfreck starfreck changed the title Fix for auto scroll issue (#179) Fix for auto scroll issue (https://github.com/Fintasys/emoji_picker_flutter/issues/179) Dec 20, 2023
@starfreck starfreck changed the title Fix for auto scroll issue (https://github.com/Fintasys/emoji_picker_flutter/issues/179) Fix for auto scroll issue Dec 20, 2023
Comment on lines 283 to 288
if (widget.scrollController != null) {
final autoScrollController = widget.scrollController!;
autoScrollController
.jumpTo(autoScrollController.position.maxScrollExtent);
}

Copy link
Owner

@Fintasys Fintasys Dec 27, 2023

Choose a reason for hiding this comment

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

Would it make sense to put it after widget.onEmojiSelected?.call(category, emoji); because if someone uses TextInputController in onEmojiSelected with then it wouldn't scroll? Same question with widget.onBackspacePressed?.call(); above

Copy link
Owner

Choose a reason for hiding this comment

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

I made a commit to version 2.0 addressing the same issue based on your code.
If you want to add the feature to v1.x of the emoji picker then it would be nice if you could check my commit and adjust your PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would it make sense to put it after widget.onEmojiSelected?.call(category, emoji); because if someone uses TextInputController in onEmojiSelected with then it wouldn't scroll? Same question with widget.onBackspacePressed?.call(); above

Yes, Indeed you are right. I have update the PR based on your changes in version 2.0

Copy link
Owner

Choose a reason for hiding this comment

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

Thanks for quick response ! Sorry, but I had to added another fix to it, would be great if you could include them as well. 8e4a287

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Fintasys I have updated the PR. Please review it. Thanks :)

Copy link
Owner

@Fintasys Fintasys left a comment

Choose a reason for hiding this comment

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

Thanks for making all the changes and your contribution ! I think it looks good now 👍

@Fintasys Fintasys merged commit ad8698c into Fintasys:master Jan 2, 2024
1 check passed
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

Successfully merging this pull request may close these issues.

[bug] TextField is not automatically scrolling when it is being updated via emoji_picker_flutter
2 participants