Skip to content

Commit 603eb82

Browse files
author
Casey Hillers
authored
Revert "Fix jumping when doing long press for selecting text" (#103141)
1 parent 0a26277 commit 603eb82

File tree

2 files changed

+0
-52
lines changed

2 files changed

+0
-52
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

-5
Original file line numberDiff line numberDiff line change
@@ -2514,11 +2514,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
25142514
_showCaretOnScreenScheduled = true;
25152515
SchedulerBinding.instance.addPostFrameCallback((Duration _) {
25162516
_showCaretOnScreenScheduled = false;
2517-
2518-
// if cursor is inactive, e.g. while selecting text, do not jump away
2519-
if (!_cursorActive) {
2520-
return;
2521-
}
25222517
if (_currentCaretRect == null || !_scrollController.hasClients) {
25232518
return;
25242519
}

packages/flutter/test/widgets/editable_text_test.dart

-47
Original file line numberDiff line numberDiff line change
@@ -5183,53 +5183,6 @@ void main() {
51835183
// toolbar. Until we change that, this test should remain skipped.
51845184
}, skip: kIsWeb); // [intended]
51855185

5186-
5187-
testWidgets('text selection handle visibility for long text', (WidgetTester tester) async {
5188-
// long text which is scrollable based on given box size
5189-
const String testText =
5190-
'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.';
5191-
final TextEditingController controller =
5192-
TextEditingController(text: testText);
5193-
final ScrollController scrollController = ScrollController();
5194-
5195-
await tester.pumpWidget(MaterialApp(
5196-
home: Align(
5197-
alignment: Alignment.topLeft,
5198-
child: SizedBox(
5199-
width: 100,
5200-
height: 100,
5201-
child: SingleChildScrollView(
5202-
controller: scrollController,
5203-
child: EditableText(
5204-
controller: controller,
5205-
showSelectionHandles: true,
5206-
focusNode: FocusNode(),
5207-
style: Typography.material2018().black.subtitle1!,
5208-
cursorColor: Colors.blue,
5209-
backgroundCursorColor: Colors.grey,
5210-
selectionControls: materialTextSelectionControls,
5211-
keyboardType: TextInputType.multiline,
5212-
maxLines: null,
5213-
),
5214-
),
5215-
),
5216-
),
5217-
));
5218-
5219-
// scroll to a text that is outside of the inital visible rect
5220-
scrollController.jumpTo(151);
5221-
await tester.pump();
5222-
5223-
// long press on a word to trigger a select
5224-
await tester.longPressAt(const Offset(20, 15));
5225-
// wait for adjustments of scroll area
5226-
await tester.pump();
5227-
await tester.pumpAndSettle();
5228-
5229-
// assert not jumped to top
5230-
expect(scrollController.offset, equals(151));
5231-
});
5232-
52335186
const String testText = 'Now is the time for\n' // 20
52345187
'all good people\n' // 20 + 16 => 36
52355188
'to come to the aid\n' // 36 + 19 => 55

0 commit comments

Comments
 (0)