Skip to content

Conversation

@chunhtai
Copy link
Contributor

@chunhtai chunhtai commented Jun 18, 2019

… non-obscureText

Description

Added a logic to check whether an update to selection overlay is necessary whenever editable text gets rebuilt.

Related Issues

#34607

Tests

I added the following tests:
'selection overlay will update when text grow bigger'

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I signed the CLA.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I updated/added relevant documentation (doc comments with ///).
  • All existing and new tests are passing.
  • The analyzer (flutter analyze --flutter-repo) does not report any problems on my PR.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require Flutter developers to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (Please read Handling breaking changes). Replace this with a link to the e-mail where you asked for input on this proposed change.
  • No, this is not a breaking change.

breaking change draft: https://docs.google.com/document/d/1JI-5idfRxzqcue3euGeJBuCtsEhnX7_VMeeb6Qp2Bwg/edit

@chunhtai chunhtai requested review from goderbauer and justinmc June 18, 2019 19:46
@chunhtai chunhtai added the framework flutter/packages/flutter repository. See also f: labels. label Jun 18, 2019
Copy link
Member

Choose a reason for hiding this comment

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

remove whitespace

Copy link
Member

Choose a reason for hiding this comment

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

nit: // instead of ///

Copy link
Member

Choose a reason for hiding this comment

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

The overlay position can change even without changes in selection, for example when the font size changes.

Copy link
Member

Choose a reason for hiding this comment

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

... if their position ...

Copy link
Member

Choose a reason for hiding this comment

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

space after if

Copy link
Member

Choose a reason for hiding this comment

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

Why else if? Don't we need to call _selectionIOverlay.update if the controller and the selection on it changed? (we should add a test to verify that this works)

Copy link
Member

Choose a reason for hiding this comment

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

Piping this back like this feels strange...

Copy link
Member

Choose a reason for hiding this comment

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

nit: indentation

Copy link
Member

Choose a reason for hiding this comment

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

tester.widgetList(find.byType(...))?

Copy link
Member

Choose a reason for hiding this comment

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

Same here.

@goderbauer
Copy link
Member

Could this be solved by having the RenderEditable insert LeaderLayers [1] where the selection handles are supposed to go and the selection handles itself are drawn on a FollowerLayer [2], which is always positioned correctly to be in the right place even when the text size in the RenderEditable changes?

See also the Widgets CompositedTransformTarget [3] and CompositedTransformFollower [4], which insert these kind of layers.

Ian mentioned that @xster was talking about doing this at some point to fix a similar class of problems.

[1] https://master-api.flutter.dev/flutter/rendering/LeaderLayer-class.html
[2] https://master-api.flutter.dev/flutter/rendering/LeaderLayer-class.html
[3] https://master-api.flutter.dev/flutter/widgets/CompositedTransformTarget-class.html
[4] https://master-api.flutter.dev/flutter/widgets/CompositedTransformFollower-class.html

@chunhtai chunhtai changed the title Selection handles position is off when switch between obscureText and… WIP Selection handles position is off - big refactor incoming Jun 20, 2019
@xster
Copy link
Member

xster commented Jun 21, 2019

+1. @matthew-carroll had a prototype implementing the iOS text selection magnifier using this approach.

@chunhtai chunhtai force-pushed the issues/34607 branch 2 times, most recently from b0d3a45 to 7ef13d0 Compare June 24, 2019 20:02
@chunhtai chunhtai changed the title WIP Selection handles position is off - big refactor incoming Selection handles position is off Jun 24, 2019
@chunhtai
Copy link
Contributor Author

finished refactoring ready for review

@justinmc
Copy link
Contributor

This made the Cupertino handles appear on the next line when I tried it:

@chunhtai
Copy link
Contributor Author

This made the Cupertino handles appear on the next line when I tried it:

thanks for catching this bug, I refined the offset calculation.

@justinmc
Copy link
Contributor

Thanks for the fix! The handles look right to me now.

@justinmc
Copy link
Contributor

Another thing I'm noticing is that the interactivity improvements that I made in #31852 seem to be gone here. The handles are very hard to touch for both Material and Cupertino.

@chunhtai
Copy link
Contributor Author

Another thing I'm noticing is that the interactivity improvements that I made in #31852 seem to be gone here. The handles are very hard to touch for both Material and Cupertino.

It turns out I removed a bunch of them when i was experimenting the offset calculation. Added back

@justinmc
Copy link
Contributor

Thanks, the handles feel great now.

I've got one more "QA" bug for you, sorry for the bombardment haha. The handle sometimes appears outside the input for both TextField and CupertinoTextField:

handle_outside

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.

See my concern about breaking changes. Otherwise this looks pretty good and seems to work great now. I like the LayerLink approach.

Copy link
Contributor

Choose a reason for hiding this comment

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

Capital F

Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a breaking change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor

Choose a reason for hiding this comment

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

More potential breaking changes.

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

Please update the PR with the breaking changes.

Copy link
Member

Choose a reason for hiding this comment

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

Update the documentation to describe what this parameter is?

Copy link
Member

Choose a reason for hiding this comment

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

the -> The

Also, this probably deserves a slightly more detailed documentation.

Copy link
Member

Choose a reason for hiding this comment

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

capital H for Handle?

Copy link
Member

Choose a reason for hiding this comment

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

nit: add trailing comma and indent by two spaces.

Copy link
Member

Choose a reason for hiding this comment

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

same.

Copy link
Member

Choose a reason for hiding this comment

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

Since we always require two: would it be more meaningful to just have to separate parameters with meaningful names instead of a list?

Copy link
Member

Choose a reason for hiding this comment

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

(e.g. leading/trailingHandleLayerLink)?

Copy link
Member

Choose a reason for hiding this comment

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

same elsewhere where the list is used.

Copy link
Member

Choose a reason for hiding this comment

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

nit: remove space before :

Copy link
Member

Choose a reason for hiding this comment

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

This is surprising, why does the textDirection determine the handle type?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

textdirection will change the order of handles
ltr:
start -> left handle, end -> right handle
rtl:
start -> right handle, end -> left handle

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but I think i can avoid this parameter, I was thinking of getting rid of renderObject dependency from this class, but it seems I will still need it to calculate the handlesize

@chunhtai chunhtai added the c: API break Backwards-incompatible API changes label Jul 1, 2019
@Piinks Piinks added the a: text input Entering text in a text field or keyboard related problems label Jul 1, 2019
@chunhtai
Copy link
Contributor Author

chunhtai commented Jul 1, 2019

Addressed comment, attached break change email draft. Ready for review

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.

LGTM. I requested access to the breaking change email, so I'll take a look at that later.

Update: Got access and it looks good too!

Copy link
Member

@goderbauer goderbauer left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

Choose a reason for hiding this comment

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

nit [LayerLink]

Copy link
Member

Choose a reason for hiding this comment

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

same

Copy link
Member

Choose a reason for hiding this comment

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

nit: Just group these three together without blank lines in between since they are logically similar.

@chunhtai chunhtai merged commit f143fd6 into flutter:master Jul 3, 2019
tango5614 added a commit to tango5614/flutter that referenced this pull request Jul 4, 2019
* commit 'a0c47e2216a2b50b70c478001cf5652f31a783af': (187 commits)
  Do not use ideographic baseline for RenderPargraph baseline (flutter#35493)
  Add type to StreamChannel in generated test code. (flutter#35367)
  Fix RenderFittedBox when child.size.isEmpty (flutter#35487)
  add APK build time benchmarks (flutter#35481)
  fix Selection handles position is off (flutter#34665)
  Move usage flutter create tests into memory filesystem. (flutter#35160)
  Include tags in SemanticsNode debug properties (flutter#35491)
  Re-apply 'Add currentSystemFrameTimeStamp to SchedulerBinding' (flutter#35492)
  CupertinoTextField vertical alignment (flutter#34723)
  Mark update-packages as non-experimental (flutter#35467)
  fix default artifacts to exclude ios and android (flutter#35303)
  Roll engine ffba2f6..7d3e722 (59 commits) (flutter#35489)
  Update macrobenchmarks README and app name (flutter#35477)
  mark windows and macos chrome dev mode as flaky (flutter#35495)
  Use the new service protocol message names (flutter#35482)
  Manual roll of engine 45b66b7...ffba2f6 (flutter#35464)
  more ui-as-code (flutter#35393)
  update reassemble doc (flutter#35164)
  New parameter for RawGestureDetector to customize semantics mapping (flutter#33936)
  Add --target support for Windows and Linux (flutter#34660)
  ...
johnsonmh pushed a commit to johnsonmh/flutter that referenced this pull request Jul 30, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

a: text input Entering text in a text field or keyboard related problems c: API break Backwards-incompatible API changes framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants