Selection handles position is off#34665
Conversation
There was a problem hiding this comment.
The overlay position can change even without changes in selection, for example when the font size changes.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Piping this back like this feels strange...
There was a problem hiding this comment.
tester.widgetList(find.byType(...))?
|
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 |
|
+1. @matthew-carroll had a prototype implementing the iOS text selection magnifier using this approach. |
b0d3a45 to
7ef13d0
Compare
|
finished refactoring ready for review |
|
Thanks for the fix! The handles look right to me now. |
|
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
left a comment
There was a problem hiding this comment.
See my concern about breaking changes. Otherwise this looks pretty good and seems to work great now. I like the LayerLink approach.
There was a problem hiding this comment.
Is this a breaking change?
There was a problem hiding this comment.
More potential breaking changes.
goderbauer
left a comment
There was a problem hiding this comment.
Please update the PR with the breaking changes.
There was a problem hiding this comment.
Update the documentation to describe what this parameter is?
There was a problem hiding this comment.
the -> The
Also, this probably deserves a slightly more detailed documentation.
There was a problem hiding this comment.
nit: add trailing comma and indent by two spaces.
There was a problem hiding this comment.
Since we always require two: would it be more meaningful to just have to separate parameters with meaningful names instead of a list?
There was a problem hiding this comment.
(e.g. leading/trailingHandleLayerLink)?
There was a problem hiding this comment.
same elsewhere where the list is used.
There was a problem hiding this comment.
This is surprising, why does the textDirection determine the handle type?
There was a problem hiding this comment.
textdirection will change the order of handles
ltr:
start -> left handle, end -> right handle
rtl:
start -> right handle, end -> left handle
There was a problem hiding this comment.
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
|
Addressed comment, attached break change email draft. Ready for review |
There was a problem hiding this comment.
nit: Just group these three together without blank lines in between since they are logically similar.
* 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) ...


… 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.///).flutter analyze --flutter-repo) does not report any problems on my PR.Breaking Change
Does your PR require Flutter developers to manually update their apps to accommodate your change?
breaking change draft: https://docs.google.com/document/d/1JI-5idfRxzqcue3euGeJBuCtsEhnX7_VMeeb6Qp2Bwg/edit