Skip to content

Commit

Permalink
Revert "Fix jumping when doing long press for selecting text" (#103141)
Browse files Browse the repository at this point in the history
  • Loading branch information
Casey Hillers authored May 5, 2022
1 parent 0a26277 commit 603eb82
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
5 changes: 0 additions & 5 deletions packages/flutter/lib/src/widgets/editable_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2514,11 +2514,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_showCaretOnScreenScheduled = true;
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
_showCaretOnScreenScheduled = false;

// if cursor is inactive, e.g. while selecting text, do not jump away
if (!_cursorActive) {
return;
}
if (_currentCaretRect == null || !_scrollController.hasClients) {
return;
}
Expand Down
47 changes: 0 additions & 47 deletions packages/flutter/test/widgets/editable_text_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5183,53 +5183,6 @@ void main() {
// toolbar. Until we change that, this test should remain skipped.
}, skip: kIsWeb); // [intended]


testWidgets('text selection handle visibility for long text', (WidgetTester tester) async {
// long text which is scrollable based on given box size
const String testText =
'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.';
final TextEditingController controller =
TextEditingController(text: testText);
final ScrollController scrollController = ScrollController();

await tester.pumpWidget(MaterialApp(
home: Align(
alignment: Alignment.topLeft,
child: SizedBox(
width: 100,
height: 100,
child: SingleChildScrollView(
controller: scrollController,
child: EditableText(
controller: controller,
showSelectionHandles: true,
focusNode: FocusNode(),
style: Typography.material2018().black.subtitle1!,
cursorColor: Colors.blue,
backgroundCursorColor: Colors.grey,
selectionControls: materialTextSelectionControls,
keyboardType: TextInputType.multiline,
maxLines: null,
),
),
),
),
));

// scroll to a text that is outside of the inital visible rect
scrollController.jumpTo(151);
await tester.pump();

// long press on a word to trigger a select
await tester.longPressAt(const Offset(20, 15));
// wait for adjustments of scroll area
await tester.pump();
await tester.pumpAndSettle();

// assert not jumped to top
expect(scrollController.offset, equals(151));
});

const String testText = 'Now is the time for\n' // 20
'all good people\n' // 20 + 16 => 36
'to come to the aid\n' // 36 + 19 => 55
Expand Down

0 comments on commit 603eb82

Please sign in to comment.