Repository navigation
Conversation
With shift_enter=True, the Enter key handler fired on_submit and returned KeyEventResult.handled even while an IME was composing, stealing the Enter that confirms a candidate and sending the raw composing text (e.g. pinyin). Skip the submit branch while TextEditingValue.composing is valid so the Enter reaches the input method and commits the candidate instead. Applies to both TextField and CupertinoTextField.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Note: reported and fixed directly in this PR — no separate issue was filed.
With
shift_enter=True, when typing with an IME (Chinese / Japanese / Korean), the composing text (e.g. pinyinnihao) is shown in the input field. Pressing Enter sends this raw composing text immediately, instead of first committing it into the field.Expected: the first Enter commits the composing letters (e.g.
nihao) directly into the field as plain text; a second Enter, when no longer composing, sends it.Root cause
_handleTextFieldKeyEventinpackages/flet/lib/src/controls/textfield.dart(and the Cupertino variant) firessubmiton Enter whenever Shift is not pressed, and returnsKeyEventResult.handled. It never checks the IME composing state, so the Enter that should commit the text is consumed as a submit and the IME never gets to commit. This affects both desktop and web (same Dart code).Fix
Skip the submit branch while the IME is composing, so Enter reaches the input method and commits the text into the field:
TextEditingValue.composingis a validTextRangeonly during active composition; when not composing it isTextRange.empty(isValid == false), so normal Enter-to-submit is unchanged. Applied to bothTextFieldandCupertinoTextField.Summary by Sourcery
Bug Fixes: