This repository was archived by the owner on Feb 25, 2025. It is now read-only.
[webui] Trigger TextInputAction.next/newline on tab/enter keypresses in single line text input elements. #12372
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.
On the web the expected behaviour of single line TextField / TextFormFields is that pressing tab will move the focus to the next input element. Switching focus between input elements is usually done in the onFieldSubmitted callback on mobile platforms (see also: editable_text.dart#L854) . Currently this is not possible on the web as TextEditingElement will never send a TextInputAction to flutter. This would in turn trigger the onFieldSubmitted callback (editable_text.dart#L1210) .
This PR changes TextEditingElement so that it will send a TextInputAction.next to flutter if the user presses the tab key and TextInputAction.newline if the enter key was pressed. It is also possible to distinguish between both action in the onFieldSubmitted callback as the TextField will automatically lose focus for TextInputAction.newline but not for TextInputAction.next (as documented in onEditingComplete ). Consequently the expected behaviour (tab -> next field, enter -> submit form) can be implemented in the onFieldSubmitted callback as in the following example: