这是indexloc提供的服务,不要输入任何密码
Skip to content

Move platform specific text selection behavior out of styled TextField classes #155774

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

Merged
merged 7 commits into from
Sep 30, 2024

Conversation

Renzo-Olivares
Copy link
Contributor

@Renzo-Olivares Renzo-Olivares commented Sep 26, 2024

Fixes #129726

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

@github-actions github-actions bot added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Sep 26, 2024
renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
if (previousSelection == editableText.textEditingValue.selection
&& renderEditable.hasFocus
&& !editableText.widget.readOnly) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I use renderEditable.readOnly instead?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion but I lean renderEditable.readOnly I guess? I'm thinking it's best to use the most narrowly scoped thing possible. Maybe in the future this method could only use renderEditable and not editableText, for example.

@Renzo-Olivares Renzo-Olivares marked this pull request as ready for review September 27, 2024 07:54
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a solid refactor, thanks for cleaning this up. Is there anything in Cupertino that can be similarly removed? I think originally iOS-specific behavior was put into Cupertino in places like _CupertinoTextFieldSelectionGestureDetectorBuilder, but really that platform-specific behavior should be in the widgets library.

renderEditable.selectWordEdge(cause: SelectionChangedCause.tap);
if (previousSelection == editableText.textEditingValue.selection
&& renderEditable.hasFocus
&& !editableText.widget.readOnly) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong opinion but I lean renderEditable.readOnly I guess? I'm thinking it's best to use the most narrowly scoped thing possible. Maybe in the future this method could only use renderEditable and not editableText, for example.

Comment on lines +2482 to +2483
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's hard to tell from the diff but I think this indentation is wrong?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll double check!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is right, the nested switch makes it look a little off.

@Renzo-Olivares
Copy link
Contributor Author

Renzo-Olivares commented Sep 27, 2024

@justinmc I didn't really see anything we could pull out of CupertinoTextFields implementation.

It mainly just has this,

// Because TextSelectionGestureDetector listens to taps that happen on
// widgets in front of it, tapping the clear button will also trigger
// this handler. If the clear button widget recognizes the up event,
// then do not handle it.
if (_state._clearGlobalKey.currentContext != null) {
final RenderBox renderBox = _state._clearGlobalKey.currentContext!.findRenderObject()! as RenderBox;
final Offset localOffset = renderBox.globalToLocal(details.globalPosition);
if (renderBox.hitTest(BoxHitTestResult(), position: localOffset)) {
return;
}
}

which seems CupertinoTextField specific since it handles the clear button behavior, so I think that's okay to stay there.

There's also


but i'm not quite sure what it's purpose is there for, and the git blame doesn't tell me much either. Removing it doesn't break any tests, do you have any thoughts?

@Renzo-Olivares
Copy link
Contributor Author

Talked offline about #155774 (comment) , will investigate

at a later time.

@Renzo-Olivares Renzo-Olivares added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 30, 2024
@auto-submit auto-submit bot merged commit 72edaa3 into flutter:master Sep 30, 2024
74 checks passed
thejitenpatel pushed a commit to thejitenpatel/flutter that referenced this pull request Oct 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 1, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 2, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 3, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 4, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 5, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 6, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 6, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 7, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 8, 2024
Manual roll Flutter from ead6b0d to 6bba08c (37 revisions)

Manual roll requested by stuartmorgan@google.com

flutter/flutter@ead6b0d...6bba08c

2024-10-01 a.a.ustinoff@gmail.com  Feat: Add opportunity to change CupertinoTextField suffix alignment (flutter/flutter#154601)
2024-10-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from da28db8ff41d to 3fdb546bf595 (2 revisions) (flutter/flutter#155993)
2024-10-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6b21b796cc94 to da28db8ff41d (1 revision) (flutter/flutter#155985)
2024-10-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 259f56c6e91b to 6b21b796cc94 (1 revision) (flutter/flutter#155983)
2024-10-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from 6ee04ed763d9 to 259f56c6e91b (1 revision) (flutter/flutter#155981)
2024-10-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from bfb6dddb2b30 to 6ee04ed763d9 (3 revisions) (flutter/flutter#155978)
2024-10-01 engine-flutter-autoroll@skia.org Roll Flutter Engine from e61bc853acb2 to bfb6dddb2b30 (8 revisions) (flutter/flutter#155967)
2024-10-01 katelovett@google.com Disable flaky menu test  (flutter/flutter#155968)
2024-10-01 robert.ancell@canonical.com Fix crash in Linux platform channel example. (flutter/flutter#155735)
2024-09-30 polinach@google.com Fix leak in input_decorator [prod-leak-fix] (flutter/flutter#155885)
2024-09-30 rmolivares@renzo-olivares.dev Move platform specific text selection behavior out of styled TextField classes (flutter/flutter#155774)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from b466a0dd7834 to e61bc853acb2 (5 revisions) (flutter/flutter#155952)
2024-09-30 rmolivares@renzo-olivares.dev `RenderParagraph`s `_SelectableFragment.boundingBoxes` should consider max line height (flutter/flutter#155892)
2024-09-30 engine-flutter-autoroll@skia.org Roll Packages from 0321757 to 27c9853 (3 revisions) (flutter/flutter#155945)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from f4507e7a4beb to b466a0dd7834 (1 revision) (flutter/flutter#155944)
2024-09-30 andrewrkolos@gmail.com when `ResidentRunner.tryInitLogReader` fails, only log warning on Android (flutter/flutter#155800)
2024-09-30 gordin.dan@gmail.com Move FlutterLogo from material to widget (flutter/flutter#155864)
2024-09-30 lizhuo.huang@outlook.com fix: support android 15 16k page size for template plugin_ffi  (flutter/flutter#155508)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from daf126b38b8f to f4507e7a4beb (1 revision) (flutter/flutter#155932)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 734205fbcd62 to daf126b38b8f (1 revision) (flutter/flutter#155929)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 338f09c4ea72 to 734205fbcd62 (1 revision) (flutter/flutter#155923)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 897f5caffe2d to 338f09c4ea72 (2 revisions) (flutter/flutter#155917)
2024-09-30 engine-flutter-autoroll@skia.org Roll Flutter Engine from 569abc4044b8 to 897f5caffe2d (1 revision) (flutter/flutter#155912)
2024-09-29 engine-flutter-autoroll@skia.org Roll Flutter Engine from c4784aa7eade to 569abc4044b8 (2 revisions) (flutter/flutter#155894)
2024-09-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from ff4541712df4 to c4784aa7eade (2 revisions) (flutter/flutter#155889)
2024-09-28 50643541+Mairramer@users.noreply.github.com Fixes column text width calculation in CupertinoDatePicker (flutter/flutter#151128)
2024-09-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 380fd814448c to ff4541712df4 (1 revision) (flutter/flutter#155886)
2024-09-28 tessertaha@gmail.com Optimize `Overlay` sample to avoid overflow (flutter/flutter#155861)
2024-09-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from f3b11bcd9c37 to 380fd814448c (1 revision) (flutter/flutter#155876)
2024-09-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from 9c8e5cb226e4 to f3b11bcd9c37 (3 revisions) (flutter/flutter#155865)
2024-09-28 engine-flutter-autoroll@skia.org Roll Flutter Engine from f9e4ed28f103 to 9c8e5cb226e4 (1 revision) (flutter/flutter#155857)
2024-09-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from f21f2b232b8a to f9e4ed28f103 (2 revisions) (flutter/flutter#155855)
2024-09-27 45459898+RamonFarizel@users.noreply.github.com Add  magnificationScale to CupertinoMagnifier for Zoom Effect (flutter/flutter#155276)
2024-09-27 iNoles@users.noreply.github.com Fix typo on theme_data (flutter/flutter#155644)
2024-09-27 engine-flutter-autoroll@skia.org Roll Flutter Engine from 7c603de2dca7 to f21f2b232b8a (6 revisions) (flutter/flutter#155843)
2024-09-27 34871572+gmackall@users.noreply.github.com Turn the packages roller bot back on (flutter/flutter#155842)
2024-09-27 engine-flutter-autoroll@skia.org Roll Packages from f38b780 to 0321757 (4 revisions) (flutter/flutter#155832)

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 camillesimon@google.com,stuartmorgan@google.com on the revert to ensure that a human
is aware of the problem.

...
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems autosubmit Merge PR when tree becomes green via auto submit App f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Separate text input behavior and UI: TextSelectionGestureDetectorBuilder
2 participants