-
Notifications
You must be signed in to change notification settings - Fork 29.7k
moving the left handle automatically scrolls EditableText to the right handle, which doesn't happen on native #105836
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
moving the left handle automatically scrolls EditableText to the right handle, which doesn't happen on native #105836
Conversation
|
cc @chunhtai |
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.
Thanks for fixing this!
My main concern at this point is just that the isEnd parameter in methods like _handleSelectionChanged isn't very clear at first glance. It makes sense in _handleSelectionHandleChanged to describe which handle changed, but elsewhere it's not clear what it means.
Maybe it's just the naming that needs to change. You could call it handleToView and set it to an enum, either baseHandle or extentHandle. Something like that?
CC @antholeole who I think was looking at a somewhat similar issue.
|
This whole comment assumes that there's no way to drag the right handle without it already being in view. If that's a wrong assumption, then disregard :). I wonder if this is the correct solution for this problem... The reason why this is not a problem for the second selection handle is that the call to if we know that it shouldn't be called when dragging the left handle, and never does anything when dragging the right handle - do we need this call at all? Can't we just delete it and all is well? |
|
@justinmc |
|
@antholeole |
|
@justinmc |
|
If we go with @antholeole's approach, can we get rid of the idea of |
@takassh It was an old implementation of edge scrolling, I think. Edge scrolling was moved elsewhere, but this line was overlooked. I think it is the sole culprit of #105821 . When you said "passes all tests" are you including the tests you wrote for this PR? If so, I think it would be best (i.e. smallest footprint) if this PR was just deleting that line, and the tests you wrote. |
|
@justinmc @antholeole it seems |
|
@takassh So, just to be clear, when you remove the line that I mentioned, #105821 still happens? I removed that line and this is the behavior I get: Screen.Recording.2022-06-22.at.4.17.03.PM.1.movIt looks like it fixes the problem for me, unless I'm testing wrong. EDIT: Oh I see, it's behind a platform switch flag. Let me take another look, you may be right! |
|
Looks like you're right! The further calls are needed on platforms not iOS / macOS. thanks for this! |
|
@justinmc what about changing ‘SelectionChangedCause.drag’ to something like SelectionChangedCause.dragLeftHandle and SelectionChangedCause.dragRightHandle? Just a thought! |
|
This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold. For more guidance, visit Writing a golden file test for Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
|
@justinmc |
|
@takassh I'll be taking over the review on this one :) sorry about the slowness, I'll get this reviewed asap. It looks almost done though, good job! |
antholeole
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.
Can we replace all instances of "IsEnd" with something like TextSelectionHandle? This will make maintinance easier in the long run. isEnd unfortunately does not feel verbose enough.
|
Something like this: diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart
index 30f96187ba..e59d176fd9 100644
--- a/packages/flutter/lib/src/widgets/text_selection.dart
+++ b/packages/flutter/lib/src/widgets/text_selection.dart
@@ -2286,6 +2286,11 @@ class ClipboardStatusNotifier extends ValueNotifier<ClipboardStatus> with Widget
}
}
+enum TextSelectionHandleSide {
+ BaseHandle,
+ ExtentHandle
+}
+
/// An enumeration of the status of the content on the user's clipboard.
enum ClipboardStatus {
/// The clipboard content can be pasted, such as a String of nonzero length.
|
|
@antholeole however, I encountered following CI failure, and it seems not to be my failure, because I didn't touch about Could you check the CI failure? |
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.
Overall, looks good! Thanks for making the changes. @justinmc might have some more nits but after you make my changes you get my approval stamp :)
I re-ran CI, hopefully it passes. I've had the same failure on my PR's, seems the test is flaky.
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.
Why mobile?
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.
Currently I think the mobile text selection handles will appear for touch events on desktop platforms, and if so then this test would be valid on all platforms.
Long term this will be cleaned up: #106586. But for now I think this is ok as long as it passes and as long as we're consistent with the variant on all the relevant tests in this PR.
|
@antholeole Code was changed based on your comment without #105836 (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 being patient with this one, I know it had a ton of rounds.
I'm going to wait for Justin to sign off on it since he's worked a ton more with this code, but I think this is looking good.
e4398b5 to
aa01042
Compare
# Conflicts: # packages/flutter/lib/src/cupertino/text_field.dart # packages/flutter/lib/src/material/text_field.dart # packages/flutter/lib/src/widgets/text_selection.dart # packages/flutter/test/material/text_field_test.dart
aa01042 to
beb3b0f
Compare
|
@justinmc |
|
Thanks for the quick response, merged! |
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
…the right handle, which doesn't happen on native (flutter/flutter#105836)
fixes #105821
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.