Reland "Fix TextField selects all content after the application is resumed"#157399
Merged
auto-submit[bot] merged 1 commit intoflutter:masterfrom Oct 23, 2024
Conversation
M97Chahboun
pushed a commit
to M97Chahboun/flutter
that referenced
this pull request
Oct 30, 2024
…sumed" (flutter#157399) ## Description Relands flutter#156968 wich was reverted in flutter#157378 This PR makes `EditableText` aware of the lifecycle 'resumed' state to let the current selection unchanged when the application is resumed (on web and desktop, 'resumed' means the Flutter app window regained focus). Before this PR, on web and desktop, the whole content of a `TextField` was selected whenever a `TextField` gained focus. This is the correct behavior when tabbing between fields but it is not when a field regains focus after the application is resumed ## Related Issue Fixes [When switching to another browser tab or window and then going back, all text on TextField is selected automatically](flutter#156078). ## Tests Adds 1 test.
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 12, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 13, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Feb 13, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Mar 6, 2025
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/packages
that referenced
this pull request
Mar 7, 2025
9 tasks
KaushikGupta007
left a comment
There was a problem hiding this comment.
_justResumed flag being stored per EditableTextState, which was set to true on app resume for every TextField, but only reset when each individual field was focused again. This led to unreliable behavior where TextInputAction.next, tab, or programmatic focus would not auto-select text as expected on Web and Desktop after resume.
github-merge-queue bot
pushed a commit
that referenced
this pull request
Oct 29, 2025
## Description This PR tweaks the selection logic added in #157399. Before this PR (and since #157399) when the app resumed while a TextField was selected the selection of the TextField is maintained. This is the right behavior for the currently focused TextField. But when there are several TextFields, after the app resumed and the user move the focus to a another TextField, the behavior should be to select all the content of the newly focused TextField. To achieve this the `_justResumed`flag added in #157399 should be reset as soon as the focus move as it is needed only for the current focused TextField to restore its selection just after the app resumed. ## Related Issue Fixes [Pressing tab does select all content when app is resumed for TextFields which were not focused](#177650) ## Tests - Adds 1 test
walley892
pushed a commit
to walley892/flutter
that referenced
this pull request
Oct 30, 2025
## Description This PR tweaks the selection logic added in flutter#157399. Before this PR (and since flutter#157399) when the app resumed while a TextField was selected the selection of the TextField is maintained. This is the right behavior for the currently focused TextField. But when there are several TextFields, after the app resumed and the user move the focus to a another TextField, the behavior should be to select all the content of the newly focused TextField. To achieve this the `_justResumed`flag added in flutter#157399 should be reset as soon as the focus move as it is needed only for the current focused TextField to restore its selection just after the app resumed. ## Related Issue Fixes [Pressing tab does select all content when app is resumed for TextFields which were not focused](flutter#177650) ## Tests - Adds 1 test
reidbaker
pushed a commit
to AbdeMohlbi/flutter
that referenced
this pull request
Dec 10, 2025
## Description This PR tweaks the selection logic added in flutter#157399. Before this PR (and since flutter#157399) when the app resumed while a TextField was selected the selection of the TextField is maintained. This is the right behavior for the currently focused TextField. But when there are several TextFields, after the app resumed and the user move the focus to a another TextField, the behavior should be to select all the content of the newly focused TextField. To achieve this the `_justResumed`flag added in flutter#157399 should be reset as soon as the focus move as it is needed only for the current focused TextField to restore its selection just after the app resumed. ## Related Issue Fixes [Pressing tab does select all content when app is resumed for TextFields which were not focused](flutter#177650) ## Tests - Adds 1 test
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.

Description
Relands #156968 wich was reverted in #157378
This PR makes
EditableTextaware of the lifecycle 'resumed' state to let the current selection unchanged when the application is resumed (on web and desktop, 'resumed' means the Flutter app window regained focus).Before this PR, on web and desktop, the whole content of a
TextFieldwas selected whenever aTextFieldgained focus. This is the correct behavior when tabbing between fields but it is not when a field regains focus after the application is resumedRelated Issue
Fixes When switching to another browser tab or window and then going back, all text on TextField is selected automatically.
Tests
Adds 1 test.