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

Weird behaviour on pressing 'Enter' in an extended_text_field #21

Closed
aasaanapps opened this issue Aug 26, 2019 · 15 comments
Closed

Weird behaviour on pressing 'Enter' in an extended_text_field #21

aasaanapps opened this issue Aug 26, 2019 · 15 comments

Comments

@aasaanapps
Copy link

aasaanapps commented Aug 26, 2019

On pressing 'Enter' to insert a newline character to the text, the '\n' is inserted to text but the cursor does not move to the next line. It stays on the same line and moves one character back, which was kind of weird. Can you please look into the issue?

The example used is - TextSelectionControls

@zmtzawqlp
Copy link
Member

does it happen in official TextField, it's better to provide a runable demo for this

@aasaanapps
Copy link
Author

I am using the example provided in the repo. PFA the code I am running as a flutter project.
In example 1 & 3, if you press 'Enter', the cursor does not move to the next line.
In example 2, at first the cursor moves to the next line when pressing enter, but after inserting an emoji it behaves similar to example 1&3.

issue_text_field.zip

@aasaanapps
Copy link
Author

The official TextField is working fine. Please find the source code of official text field example below.

simple_text_field.zip

@zmtzawqlp
Copy link
Member

this is refer to flutter/flutter#35869
try to do selection with widgetspan, but _textPainter.getOffsetForCaret return Offset.zero when textspan has widgetspans, could you please report to flutter team about it?

getOffsetForCaret is not right for widgetspan, so i use getBoxesForSelection but it seems that it's not good for "\n"

@zmtzawqlp
Copy link
Member

flutter/flutter#38474 wait for flutter team to add support

@aasaanapps
Copy link
Author

Thanks for the quick reply :) will surely wait for them to add support.

@zmtzawqlp
Copy link
Member

i have do a workaround about this issue in extended_text_library, please run packages get, make sure extended_text_library is 0.4.9 version. please tell me if it works.

@aasaanapps
Copy link
Author

aasaanapps commented Aug 27, 2019

Nope it is still failing. I updated extended_text_library and tried it for Example 1. custom toolbar.
When I type a few words in the last line and pressed 'Enter' the cursor strangely moved back by 2 characters instead of going to the next line.

  extended_text_library:
    dependency: "direct main"
    description:
      name: extended_text_library
      url: "https://pub.dartlang.org"
    source: hosted
    version: "0.4.9"

@zmtzawqlp
Copy link
Member

I could't reproduce, which flutter sdk do you use? i'm in 1.9.5

@aasaanapps
Copy link
Author

aasaanapps commented Aug 27, 2019

I am using the stable version v1.7.8+hotfix.4

@zmtzawqlp
Copy link
Member

gif to reproduce it, will helpful if you have a time

@aasaanapps
Copy link
Author

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.7.8+hotfix.4, on Microsoft Windows [Version 10.0.18362.295], locale en-US)

[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.4)
[√] VS Code (version 1.37.1)
[!] Connected device
! No devices available

@aasaanapps
Copy link
Author

sure I will make a gif.

@aasaanapps
Copy link
Author

Might be some issue with caching .. I closed everything .. opened the project again .. did a pub get again .. and ran the project .. the issue is no longer there (weird!).

Thanks for the fix. Cheers!

@zmtzawqlp
Copy link
Member

I'm glad to solve it with workaround for now, let us await for official fixing of widgetspan

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

1 participant