-
Notifications
You must be signed in to change notification settings - Fork 28.7k
"Select All" Automatically scrolls EditableText to the end of the text field, which doesn't happen on native iOS #105799
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
Conversation
@@ -207,7 +207,6 @@ abstract class TextSelectionControls { | |||
/// by the user. | |||
void handleSelectAll(TextSelectionDelegate delegate) { | |||
delegate.selectAll(SelectionChangedCause.toolbar); | |||
delegate.bringIntoView(delegate.textEditingValue.selection.extent); |
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.
I believe this is redundant: it seems like the default editableTextState.selectAll
calls scrollIntoView. Nothing that tests this directly, either
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.
Looks like you're right and it should be removed. I'll be deprecating handleSelectAll soon and hopefully removing the opportunity for things like this to happen.
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 as a small separate PR. Just some small comments and questions but overall it looks good.
@@ -1796,8 +1796,20 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien | |||
), | |||
cause, | |||
); | |||
|
|||
/// The only known current platform that does not bring into view is iOS. |
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.
This should be a double slash.
@@ -207,7 +207,6 @@ abstract class TextSelectionControls { | |||
/// by the user. | |||
void handleSelectAll(TextSelectionDelegate delegate) { | |||
delegate.selectAll(SelectionChangedCause.toolbar); | |||
delegate.bringIntoView(delegate.textEditingValue.selection.extent); |
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.
Looks like you're right and it should be removed. I'll be deprecating handleSelectAll soon and hopefully removing the opportunity for things like this to happen.
@@ -529,7 +528,7 @@ class TextSelectionOverlay { | |||
} | |||
} | |||
|
|||
/// An object that manages a pair of selection handles. | |||
/// An object that manages a pair of selection handles and a toolbar. |
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.
Good catch!
final TextEditingController controller = TextEditingController(text: text); | ||
final ScrollController scrollController = ScrollController(); | ||
group('Selection changed scroll into view', () { | ||
final String text = List<int>.generate(64, (int index) => index).join('\n'); |
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.
The indentation is wrong here, this should be outdented.
|
||
final TextSelectionDelegate textSelectionDelegate = key.currentState!; | ||
/// Populate [maxScrollExtent] |
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.
Period here.
await resetSelectionAndScrollOffset(tester, false); | ||
textSelectionDelegate.selectAll(SelectionChangedCause.toolbar); | ||
await tester.pump(); | ||
expect(scrollController.offset.roundToDouble(), maxScrollExtent); |
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.
I would have thought that this test would also be run on iOS and that it shouldn't scroll in that case (0.0), but it looks like it's passing so I'm wrong. What am I misunderstanding?
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.
"In a test environment, the platform returned is TargetPlatform.android regardless of the host platform." from here. You're right that this is implicit and looks weird... I read this when I was writing the code, but your comment had me scratching my head for a little because it's so implicit :). I'll explicitly run it on all other platforms but skip mac and iOS.
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.
Or in EditableText should you be switching on Theme.of(context).targetPlatform
instead of defaultTargetPlatform
?
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.
Talked offline - defaultTargetPlatform seems better in this case
expect(scrollController.offset, 0.0); | ||
}, variant: const TargetPlatformVariant(<TargetPlatform>{ TargetPlatform.iOS })); |
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.
Nit: Would it be useful to run this test on all platforms and put this final expect
in a switch
to show what the different behavior is? Or maybe that's covered by the next test anyway.
@@ -1796,8 +1796,20 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien | |||
), | |||
cause, | |||
); | |||
|
|||
/// The only known current platform that does not bring into view is iOS. | |||
if (cause == SelectionChangedCause.toolbar) { |
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.
does Ctrl-A scroll to the end on iOS?
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.
This is a good call - I wasn't thinking about the keyboard on iOS world. I'd need someone else to test and verify, I Don't have access to an iOS device keyboard.
Good call, I'll ask around tomorrow.
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.
Tried on simulator with "Send Keyboard Input to Device" on, it didn't scroll. On macOS it doesn't seem to scroll either (for single/multiline text fields. Only chrome scrolls to the end of the text in its omnibox).
Actually scratch this, reverting. This logic is too unique. |
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 👍
There are two failing tests, but they look like flutter_svg tests that I often see flake. I would guess that rebasing on master and squashing all the commits in this PR or reopening a new PR would make them pass.
(triage): @antholeole can you follow up on the feedback from above so we can get this merged? Thanks! |
Yes, sorry. Lots of momentum on loupe, been meaning to come back to this. Switching gears rn |
(Triage): Looks like this is failing a customer test... |
Oopsie |
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.
Renewing my LGTM 👍
…tter#105799) Co-authored-by: Anthony Oleinik <[email protected]>
Oh wow. Thanks for taking a deeper look. You or Justin will have to show me how to simulate keyboard stuff on simulator :). You’re also right on the MacOS front - good catch on the Omnibox, I was testing there!
Will update this PR tomorrow - tyvm!
… On Jun 16, 2022, at 6:04 PM, LongCatIsLooong ***@***.***> wrote:
@LongCatIsLooong commented on this pull request.
In packages/flutter/lib/src/widgets/editable_text.dart:
> @@ -1796,8 +1796,20 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
),
cause,
);
+
+ /// The only known current platform that does not bring into view is iOS.
if (cause == SelectionChangedCause.toolbar) {
Tried on simulator with "Send Keyboard Input to Device" on, it didn't scroll. On macOS it doesn't seem to scroll either (for single/multiline text fields. Only chrome scrolls to the end of the text in its omnibox).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.
|
Fixes:
Pre-launch Checklist
///
).