You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[macOS] TextField lost input event after composing text deleted #100272
This also reproduces with macOS Japanese - Romaji input method.
To be very slightly more specific with the repro steps:
Input and commit some text into a textfield. A simple option would be the text 'hello'.
Switch the system input method to Pinyin or Japanese.
Begin typing some composing text but do not commit. e.g. 'nihao'
Press backspace until the composing region is empty.
While remaining in Pinyin or Japanese mode, type a character such as 'n'. Note that backspace works as expected here; input characters do not.
Expected behaviour: composing region now contains the character typed (e.g. 'n')
Actual behaviour: composing region contains nothing, IME candidate menu pops up at screen position (0,0), but contains the correct composing text.
I haven't tried debugging this, but I suspect that we've got an off-by-one error in how we set the composing state. In other words, we're leaving TextInputModel in composing mode after the last character is deleted, or we're failing to begin composing and activate the IME once the first new character is typed after deleting all text in the composing range.
A couple more hints at what's going on here:
the IME candidates menu position is the combination of two inputs. I'm going from memory here, so we'll want to double-check this, but one is the composing rect in window co-ordinates, the other is a coordinate transform matrix. I suspect we only apply/update the position in screen co-ordinates when we're composing, which would be further evidence that we're not in composing mode when we type that first character after deleting all text in the composing range.
the IME candidates popup contains the correct composing text but it's clear that we're not sending this from the engine to the framework and possibly (probably?) not updating the composing text in TextInputModel.
The NSTextInputContext we use in the text input plugin seems to be deactivating itself whenever the composing region is deleted, without even calling NSTextInputContext.deactive. There's a NSTextInputContext.isActive private method that can be used to confirm this.
The right fix seems to be properly incorporate FlutterTextInputPlugin into the responder chain (or view hierarchy), and make it the primary focus when it's supposed to be taking input. But I think the change is going to be substantial. Calling [_textInputContext activate] before [_textInputContext handleEvent:] also seems to work but it's quite hacky.
@cbracken I was planning to repurpose this issue for properly setting up the responder chain on macOS for text input. Should I create a new issue instead?
Ah thanks; this was listed on the stable blockers dashboard and had moved it to done. Thanks for creating a new issue for the proper strategic fix for this!
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
cbracken commentedon Mar 17, 2022
/cc @LongCatIsLooong (and myself)
cbracken commentedon Mar 17, 2022
This also reproduces with macOS Japanese - Romaji input method.
To be very slightly more specific with the repro steps:
Expected behaviour: composing region now contains the character typed (e.g. 'n')
Actual behaviour: composing region contains nothing, IME candidate menu pops up at screen position (0,0), but contains the correct composing text.
I haven't tried debugging this, but I suspect that we've got an off-by-one error in how we set the composing state. In other words, we're leaving TextInputModel in composing mode after the last character is deleted, or we're failing to begin composing and activate the IME once the first new character is typed after deleting all text in the composing range.
A couple more hints at what's going on here:
TextInputModel.LongCatIsLooong commentedon Mar 18, 2022
The
NSTextInputContextwe use in the text input plugin seems to be deactivating itself whenever the composing region is deleted, without even callingNSTextInputContext.deactive. There's aNSTextInputContext.isActiveprivate method that can be used to confirm this.The right fix seems to be properly incorporate
FlutterTextInputPlugininto the responder chain (or view hierarchy), and make it the primary focus when it's supposed to be taking input. But I think the change is going to be substantial. Calling[_textInputContext activate]before[_textInputContext handleEvent:]also seems to work but it's quite hacky.cbracken commentedon Mar 22, 2022
This was resolved in flutter-team-archive/engine#32117.
LongCatIsLooong commentedon Mar 22, 2022
@cbracken I was planning to repurpose this issue for properly setting up the responder chain on macOS for text input. Should I create a new issue instead?
LongCatIsLooong commentedon Mar 22, 2022
Created #100590
cbracken commentedon Mar 23, 2022
Ah thanks; this was listed on the stable blockers dashboard and had moved it to done. Thanks for creating a new issue for the proper strategic fix for this!
github-actions commentedon Apr 6, 2022
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.