-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Reland "Fix TextField selects all content after the application is resumed" #157399
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
Reland "Fix TextField selects all content after the application is resumed" #157399
Conversation
gspencergoog
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…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.
KaushikGupta007
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_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.
## 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
## 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
## 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

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.