-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Fix TextField content should be selected on desktop when gaining focus #154916
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
Fix TextField content should be selected on desktop when gaining focus #154916
Conversation
justinmc
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.
LGTM 👍 Thanks for fixing this. I think I have looked at this kind of thing in the past but maybe missed some cases. See below about leaving a comment explaining which platforms you tried this behavior on.
| final bool shouldSelectAll = widget.selectionEnabled | ||
| && (kIsWeb || isDesktop) | ||
| && !_isMultiline | ||
| && !_nextFocusChangeIsInternal; |
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.
Could you leave a comment explaining what platforms you tested here? For the future in case someone considers updating this code.
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.
There was an existing comment on line 4387 that I updated do you think this comment is enough? I checked that this is the expected behavior on Linux, macOS and Windows, and also that is not expected on iOS and Android.
flutter/flutter@303f222...2d30fe4 2024-09-13 [email protected] Roll Packages from 91caa7a to 330581f (4 revisions) (flutter/flutter#155171) 2024-09-13 [email protected] Fix: Flicker when reorderable list doesn't change its position (flutter/flutter#151026) 2024-09-13 [email protected] Stop reading .packages from flutter_tools. (flutter/flutter#154912) 2024-09-13 [email protected] Roll Flutter Engine from 70109e3b40c0 to bef48e87f438 (1 revision) (flutter/flutter#155156) 2024-09-13 [email protected] Roll Flutter Engine from d917a15823f3 to 70109e3b40c0 (1 revision) (flutter/flutter#155151) 2024-09-13 [email protected] Roll Flutter Engine from 94696ed75dea to d917a15823f3 (1 revision) (flutter/flutter#155147) 2024-09-13 [email protected] Fix TextField content should be selected on desktop when gaining focus (flutter/flutter#154916) 2024-09-13 [email protected] Roll Flutter Engine from 04802b779045 to 94696ed75dea (1 revision) (flutter/flutter#155144) 2024-09-13 [email protected] Roll Flutter Engine from 3d8163f47919 to 04802b779045 (2 revisions) (flutter/flutter#155138) 2024-09-13 [email protected] Roll Flutter Engine from 4d5fea97e933 to 3d8163f47919 (1 revision) (flutter/flutter#155136) 2024-09-13 [email protected] Mark `_LayoutBuilderElement` as always clean (flutter/flutter#154694) 2024-09-13 [email protected] Roll Flutter Engine from 8609af642725 to 4d5fea97e933 (7 revisions) (flutter/flutter#155134) 2024-09-12 [email protected] Disable fuchsia in flutter_tools (flutter/flutter#155111) 2024-09-12 [email protected] Address frame policy benchmark flakes (flutter/flutter#155130) 2024-09-12 [email protected] Roll Flutter Engine from 48ddaf578fb0 to 8609af642725 (11 revisions) (flutter/flutter#155128) 2024-09-12 49699333+dependabot[bot]@users.noreply.github.com Bump peter-evans/create-pull-request from 7.0.1 to 7.0.2 (flutter/flutter#155126) 2024-09-12 [email protected] Prevent the keyboard from reshowing on iOS (flutter/flutter#154584) 2024-09-12 [email protected] fix(Linux): specify application id (flutter/flutter#154522) 2024-09-12 [email protected] update changelog on master (flutter/flutter#155109) 2024-09-12 [email protected] iOS: update provisioning profile for 2024-2025 cert (flutter/flutter#155101) 2024-09-12 [email protected] Roll Packages from 4c18648 to 91caa7a (2 revisions) (flutter/flutter#155103) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Description
This PR fixes the default selection on desktop when a text field is gaining focus.
Before this PR, when a text field is focused, the selection was collapsed at the end for all platforms except on Web where the entire content was selected.
After this PR, when a text field is focused, the entire content is selected on desktop and Web, and the selection is collapsed at the end on mobile platforms.
The implementation extends the work done in #119583 which implemented this feature for web.
Related Issue
Fixes #150339.
Tests
Updates 1 test.
Fixes 2 tests.