mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
Hide text selection handle after entering text (#37436)
The text caret wasn't being hidden after entering text, this fixes it.
This commit is contained in:
parent
9553f8daa7
commit
954714c967
|
@ -1657,9 +1657,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void hideToolbar() {
|
void hideToolbar() {
|
||||||
if (_selectionOverlay == null || !_selectionOverlay.toolbarIsVisible) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_selectionOverlay?.hide();
|
_selectionOverlay?.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -795,6 +795,46 @@ void main() {
|
||||||
expect(handle.opacity.value, equals(1.0));
|
expect(handle.opacity.value, equals(1.0));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Entering text hides selection handle caret', (WidgetTester tester) async {
|
||||||
|
final TextEditingController controller = TextEditingController();
|
||||||
|
|
||||||
|
await tester.pumpWidget(
|
||||||
|
overlay(
|
||||||
|
child: TextField(
|
||||||
|
controller: controller,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const String testValue = 'abcdefghi';
|
||||||
|
await tester.enterText(find.byType(TextField), testValue);
|
||||||
|
expect(controller.value.text, testValue);
|
||||||
|
await skipPastScrollingAnimation(tester);
|
||||||
|
|
||||||
|
// Handle not shown.
|
||||||
|
expect(controller.selection.isCollapsed, true);
|
||||||
|
final Finder fadeFinder = find.byType(FadeTransition);
|
||||||
|
expect(fadeFinder, findsNothing);
|
||||||
|
|
||||||
|
// Tap on the text field to show the handle.
|
||||||
|
await tester.tap(find.byType(TextField));
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
expect(controller.selection.isCollapsed, true);
|
||||||
|
expect(fadeFinder, findsNWidgets(1));
|
||||||
|
final FadeTransition handle = tester.widget(fadeFinder.at(0));
|
||||||
|
expect(handle.opacity.value, equals(1.0));
|
||||||
|
|
||||||
|
// Enter more text.
|
||||||
|
const String testValueAddition = 'jklmni';
|
||||||
|
await tester.enterText(find.byType(TextField), testValueAddition);
|
||||||
|
expect(controller.value.text, testValueAddition);
|
||||||
|
await skipPastScrollingAnimation(tester);
|
||||||
|
|
||||||
|
// Handle not shown.
|
||||||
|
expect(controller.selection.isCollapsed, true);
|
||||||
|
expect(fadeFinder, findsNothing);
|
||||||
|
});
|
||||||
|
|
||||||
testWidgets('Mouse long press is just like a tap', (WidgetTester tester) async {
|
testWidgets('Mouse long press is just like a tap', (WidgetTester tester) async {
|
||||||
final TextEditingController controller = TextEditingController();
|
final TextEditingController controller = TextEditingController();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue