Unverified Commit 85b4670b authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Revert "Implement Double Tap Handling in TextField and Editable" (#22051)

* Revert "Revert "Add RichText support to find.text" (#22046)"

This reverts commit 8e704219.

* Revert "Implement Double Tap Handling in TextField and Editable (#21264)"

This reverts commit 02e87334.
parent 8e704219
...@@ -496,11 +496,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -496,11 +496,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
_cancelCurrentSplash(); _cancelCurrentSplash();
} }
void _handleDoubleTap() {
_renderEditable.handleDoubleTap();
_confirmCurrentSplash();
}
void _handleLongPress() { void _handleLongPress() {
_renderEditable.handleLongPress(); _renderEditable.handleLongPress();
_confirmCurrentSplash(); _confirmCurrentSplash();
...@@ -619,7 +614,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi ...@@ -619,7 +614,6 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
onTapDown: _handleTapDown, onTapDown: _handleTapDown,
onTap: _handleTap, onTap: _handleTap,
onTapCancel: _handleTapCancel, onTapCancel: _handleTapCancel,
onDoubleTap: _handleDoubleTap,
onLongPress: _handleLongPress, onLongPress: _handleLongPress,
excludeFromSemantics: true, excludeFromSemantics: true,
child: child, child: child,
......
...@@ -32,10 +32,6 @@ enum SelectionChangedCause { ...@@ -32,10 +32,6 @@ enum SelectionChangedCause {
/// of the cursor) to change. /// of the cursor) to change.
tap, tap,
/// The user tapped twice in quick succession on the text and that caused
/// the selection (or the location of the cursor) to change.
doubleTap,
/// The user long-pressed the text and that caused the selection (or the /// The user long-pressed the text and that caused the selection (or the
/// location of the cursor) to change. /// location of the cursor) to change.
longPress, longPress,
...@@ -172,8 +168,6 @@ class RenderEditable extends RenderBox { ...@@ -172,8 +168,6 @@ class RenderEditable extends RenderBox {
_tap = TapGestureRecognizer(debugOwner: this) _tap = TapGestureRecognizer(debugOwner: this)
..onTapDown = _handleTapDown ..onTapDown = _handleTapDown
..onTap = _handleTap; ..onTap = _handleTap;
_doubleTap = DoubleTapGestureRecognizer(debugOwner: this)
..onDoubleTap = _handleDoubleTap;
_longPress = LongPressGestureRecognizer(debugOwner: this) _longPress = LongPressGestureRecognizer(debugOwner: this)
..onLongPress = _handleLongPress; ..onLongPress = _handleLongPress;
} }
...@@ -191,7 +185,7 @@ class RenderEditable extends RenderBox { ...@@ -191,7 +185,7 @@ class RenderEditable extends RenderBox {
/// If true [handleEvent] does nothing and it's assumed that this /// If true [handleEvent] does nothing and it's assumed that this
/// renderer will be notified of input gestures via [handleTapDown], /// renderer will be notified of input gestures via [handleTapDown],
/// [handleTap], [handleDoubleTap], and [handleLongPress]. /// [handleTap], and [handleLongPress].
/// ///
/// The default value of this property is false. /// The default value of this property is false.
bool ignorePointer; bool ignorePointer;
...@@ -1028,7 +1022,6 @@ class RenderEditable extends RenderBox { ...@@ -1028,7 +1022,6 @@ class RenderEditable extends RenderBox {
bool hitTestSelf(Offset position) => true; bool hitTestSelf(Offset position) => true;
TapGestureRecognizer _tap; TapGestureRecognizer _tap;
DoubleTapGestureRecognizer _doubleTap;
LongPressGestureRecognizer _longPress; LongPressGestureRecognizer _longPress;
@override @override
...@@ -1038,7 +1031,6 @@ class RenderEditable extends RenderBox { ...@@ -1038,7 +1031,6 @@ class RenderEditable extends RenderBox {
assert(debugHandleEvent(event, entry)); assert(debugHandleEvent(event, entry));
if (event is PointerDownEvent && onSelectionChanged != null) { if (event is PointerDownEvent && onSelectionChanged != null) {
_tap.addPointer(event); _tap.addPointer(event);
_doubleTap.addPointer(event);
_longPress.addPointer(event); _longPress.addPointer(event);
} }
} }
...@@ -1078,25 +1070,6 @@ class RenderEditable extends RenderBox { ...@@ -1078,25 +1070,6 @@ class RenderEditable extends RenderBox {
handleTap(); handleTap();
} }
/// If [ignorePointer] is false (the default) then this method is called by
/// the internal gesture recognizer's [DoubleTapGestureRecognizer.onDoubleTap]
/// callback.
///
/// When [ignorePointer] is true, an ancestor widget must respond to long
/// press events by calling this method.
void handleDoubleTap() {
_layoutText(constraints.maxWidth);
assert(_lastTapDownPosition != null);
if (onSelectionChanged != null) {
final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(_lastTapDownPosition));
onSelectionChanged(_selectWordAtOffset(position), this, SelectionChangedCause.doubleTap);
}
}
void _handleDoubleTap() {
assert(!ignorePointer);
handleDoubleTap();
}
/// If [ignorePointer] is false (the default) then this method is called by /// If [ignorePointer] is false (the default) then this method is called by
/// the internal gesture recognizer's [LongPressRecognizer.onLongPress] /// the internal gesture recognizer's [LongPressRecognizer.onLongPress]
/// callback. /// callback.
......
...@@ -179,7 +179,6 @@ void main() { ...@@ -179,7 +179,6 @@ void main() {
); );
await tester.tap(find.widgetWithText(TextField, 'TextField 2')); await tester.tap(find.widgetWithText(TextField, 'TextField 2'));
await tester.pump(const Duration(milliseconds: 300));
expect( expect(
focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)), focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)),
...@@ -190,7 +189,6 @@ void main() { ...@@ -190,7 +189,6 @@ void main() {
await tester.pump(); await tester.pump();
await tester.tap(find.widgetWithText(TextField, 'TextField 1')); await tester.tap(find.widgetWithText(TextField, 'TextField 1'));
await tester.pump(const Duration(milliseconds: 300));
expect( expect(
focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)), focusNodes.indexOf(focusNodes.singleWhere((FocusNode node) => node.hasFocus)),
......
...@@ -164,7 +164,7 @@ void main() { ...@@ -164,7 +164,7 @@ void main() {
delegate: delegate, delegate: delegate,
)); ));
await tester.tap(find.byTooltip('Search')); await tester.tap(find.byTooltip('Search'));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
// Showing suggestions // Showing suggestions
expect(find.text('Suggestions'), findsOneWidget); expect(find.text('Suggestions'), findsOneWidget);
...@@ -173,14 +173,14 @@ void main() { ...@@ -173,14 +173,14 @@ void main() {
// Typing query Wow // Typing query Wow
delegate.querysForSuggestions.clear(); delegate.querysForSuggestions.clear();
await tester.enterText(find.byType(TextField), 'Wow'); await tester.enterText(find.byType(TextField), 'Wow');
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(delegate.query, 'Wow'); expect(delegate.query, 'Wow');
expect(delegate.querysForSuggestions, <String>['Wow']); expect(delegate.querysForSuggestions, <String>['Wow']);
expect(delegate.querysForResults, hasLength(0)); expect(delegate.querysForResults, hasLength(0));
await tester.tap(find.text('Suggestions')); await tester.tap(find.text('Suggestions'));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
// Showing Results // Showing Results
expect(find.text('Suggestions'), findsNothing); expect(find.text('Suggestions'), findsNothing);
...@@ -195,7 +195,7 @@ void main() { ...@@ -195,7 +195,7 @@ void main() {
// Taping search field to go back to suggestions // Taping search field to go back to suggestions
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
textField = tester.widget(find.byType(TextField)); textField = tester.widget(find.byType(TextField));
expect(textField.focusNode.hasFocus, isTrue); expect(textField.focusNode.hasFocus, isTrue);
...@@ -206,7 +206,7 @@ void main() { ...@@ -206,7 +206,7 @@ void main() {
expect(delegate.querysForResults, <String>['Wow']); expect(delegate.querysForResults, <String>['Wow']);
await tester.enterText(find.byType(TextField), 'Foo'); await tester.enterText(find.byType(TextField), 'Foo');
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(delegate.query, 'Foo'); expect(delegate.query, 'Foo');
expect(delegate.querysForSuggestions, <String>['Wow', 'Wow', 'Foo']); expect(delegate.querysForSuggestions, <String>['Wow', 'Wow', 'Foo']);
...@@ -214,7 +214,7 @@ void main() { ...@@ -214,7 +214,7 @@ void main() {
// Go to results again // Go to results again
await tester.tap(find.text('Suggestions')); await tester.tap(find.text('Suggestions'));
await tester.pumpAndSettle(const Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(find.text('Suggestions'), findsNothing); expect(find.text('Suggestions'), findsNothing);
expect(find.text('Results'), findsOneWidget); expect(find.text('Results'), findsOneWidget);
......
...@@ -6,8 +6,6 @@ import 'package:flutter_test/flutter_test.dart'; ...@@ -6,8 +6,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
void main() { void main() {
const Duration doubleTapTimeout = Duration(milliseconds: 300);
testWidgets('Request focus shows keyboard', (WidgetTester tester) async { testWidgets('Request focus shows keyboard', (WidgetTester tester) async {
final FocusNode focusNode = FocusNode(); final FocusNode focusNode = FocusNode();
...@@ -73,7 +71,7 @@ void main() { ...@@ -73,7 +71,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
...@@ -82,7 +80,7 @@ void main() { ...@@ -82,7 +80,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
...@@ -115,17 +113,17 @@ void main() { ...@@ -115,17 +113,17 @@ void main() {
builder: (BuildContext context) => const SimpleDialog(title: Text('Dialog')), builder: (BuildContext context) => const SimpleDialog(title: Text('Dialog')),
); );
await tester.pump(doubleTapTimeout); await tester.pump();
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
Navigator.of(tester.element(find.text('Dialog'))).pop(); Navigator.of(tester.element(find.text('Dialog'))).pop();
await tester.pump(doubleTapTimeout); await tester.pump();
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
...@@ -226,7 +224,7 @@ void main() { ...@@ -226,7 +224,7 @@ void main() {
expect(tester.testTextInput.isVisible, isFalse); expect(tester.testTextInput.isVisible, isFalse);
await tester.tap(find.byType(TextField)); await tester.tap(find.byType(TextField));
await tester.pump(doubleTapTimeout); await tester.idle();
expect(tester.testTextInput.isVisible, isTrue); expect(tester.testTextInput.isVisible, isTrue);
}); });
} }
...@@ -121,32 +121,32 @@ void main() { ...@@ -121,32 +121,32 @@ void main() {
cancelCount = 0; cancelCount = 0;
await tester.tap(find.byKey(textField1)); await tester.tap(find.byKey(textField1));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 1); expect(confirmCount, 1);
expect(cancelCount, 0); expect(cancelCount, 0);
// textField1 already has the focus, no new splash // textField1 already has the focus, no new splash
await tester.tap(find.byKey(textField1)); await tester.tap(find.byKey(textField1));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 1); expect(confirmCount, 1);
expect(cancelCount, 0); expect(cancelCount, 0);
// textField2 gets the focus and a splash // textField2 gets the focus and a splash
await tester.tap(find.byKey(textField2)); await tester.tap(find.byKey(textField2));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 2); expect(confirmCount, 2);
expect(cancelCount, 0); expect(cancelCount, 0);
// Tap outside of textField1's editable. It still gets focus and splash. // Tap outside of textField1's editable. It still gets focus and splash.
await tester.tapAt(tester.getTopLeft(find.byKey(textField1))); await tester.tapAt(tester.getTopLeft(find.byKey(textField1)));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 3); expect(confirmCount, 3);
expect(cancelCount, 0); expect(cancelCount, 0);
// Tap in the center of textField2's editable. It still gets the focus // Tap in the center of textField2's editable. It still gets the focus
// and the splash. There is no splash cancel. // and the splash. There is no splash cancel.
await tester.tap(find.byKey(textField2)); await tester.tap(find.byKey(textField2));
await tester.pumpAndSettle(Duration(milliseconds: 300)); await tester.pumpAndSettle();
expect(confirmCount, 4); expect(confirmCount, 4);
expect(cancelCount, 0); expect(cancelCount, 0);
}); });
......
...@@ -20,7 +20,6 @@ void main() { ...@@ -20,7 +20,6 @@ void main() {
final FocusScopeNode focusScopeNode = FocusScopeNode(); final FocusScopeNode focusScopeNode = FocusScopeNode();
const TextStyle textStyle = TextStyle(); const TextStyle textStyle = TextStyle();
const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00); const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00);
const Duration doubleTapTimeout = Duration(milliseconds: 300);
setUp(() { setUp(() {
debugResetSemanticsIdCounter(); debugResetSemanticsIdCounter();
...@@ -54,7 +53,6 @@ void main() { ...@@ -54,7 +53,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -121,7 +119,6 @@ void main() { ...@@ -121,7 +119,6 @@ void main() {
), ),
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -285,7 +282,6 @@ void main() { ...@@ -285,7 +282,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -315,7 +311,6 @@ void main() { ...@@ -315,7 +311,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -346,7 +341,6 @@ void main() { ...@@ -346,7 +341,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -379,7 +373,6 @@ void main() { ...@@ -379,7 +373,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -410,7 +403,6 @@ void main() { ...@@ -410,7 +403,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -441,7 +433,6 @@ void main() { ...@@ -441,7 +433,6 @@ void main() {
); );
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout);
await tester.showKeyboard(find.byType(EditableText)); await tester.showKeyboard(find.byType(EditableText));
controller.text = 'test'; controller.text = 'test';
await tester.idle(); await tester.idle();
...@@ -617,7 +608,7 @@ void main() { ...@@ -617,7 +608,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -654,7 +645,7 @@ void main() { ...@@ -654,7 +645,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -698,7 +689,7 @@ void main() { ...@@ -698,7 +689,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -742,7 +733,7 @@ void main() { ...@@ -742,7 +733,7 @@ void main() {
// Select EditableText to give it focus. // Select EditableText to give it focus.
final Finder textFinder = find.byKey(editableTextKey); final Finder textFinder = find.byKey(editableTextKey);
await tester.tap(textFinder); await tester.tap(textFinder);
await tester.pump(doubleTapTimeout); await tester.pump();
assert(focusNode.hasFocus); assert(focusNode.hasFocus);
...@@ -847,7 +838,7 @@ void main() { ...@@ -847,7 +838,7 @@ void main() {
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.idle(); await tester.idle();
await tester.pump(doubleTapTimeout); await tester.pump();
expect( expect(
semantics, semantics,
...@@ -1488,7 +1479,7 @@ void main() { ...@@ -1488,7 +1479,7 @@ void main() {
await _buildApp(controls, tester); await _buildApp(controls, tester);
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout); await tester.pump();
expect( expect(
semantics, semantics,
...@@ -1574,7 +1565,7 @@ void main() { ...@@ -1574,7 +1565,7 @@ void main() {
when(controls.canPaste(any)).thenReturn(true); when(controls.canPaste(any)).thenReturn(true);
await _buildApp(controls, tester); await _buildApp(controls, tester);
await tester.tap(find.byType(EditableText)); await tester.tap(find.byType(EditableText));
await tester.pump(doubleTapTimeout); await tester.pump();
final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner; final SemanticsOwner owner = tester.binding.pipelineOwner.semanticsOwner;
const int expectedNodeId = 4; const int expectedNodeId = 4;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment