Hide toolbar after select all on desktop (#100261)
This commit is contained in:
parent
795fe375bc
commit
a217bbb6de
@ -77,6 +77,12 @@ class _CupertinoDesktopTextSelectionControls extends TextSelectionControls {
|
|||||||
Offset getHandleAnchor(TextSelectionHandleType type, double textLineHeight) {
|
Offset getHandleAnchor(TextSelectionHandleType type, double textLineHeight) {
|
||||||
return Offset.zero;
|
return Offset.zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSelectAll(TextSelectionDelegate delegate) {
|
||||||
|
super.handleSelectAll(delegate);
|
||||||
|
delegate.hideToolbar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Text selection controls that follows Mac design conventions.
|
/// Text selection controls that follows Mac design conventions.
|
||||||
|
@ -73,6 +73,12 @@ class _DesktopTextSelectionControls extends TextSelectionControls {
|
|||||||
value.text.isNotEmpty &&
|
value.text.isNotEmpty &&
|
||||||
!(value.selection.start == 0 && value.selection.end == value.text.length);
|
!(value.selection.start == 0 && value.selection.end == value.text.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void handleSelectAll(TextSelectionDelegate delegate) {
|
||||||
|
super.handleSelectAll(delegate);
|
||||||
|
delegate.hideToolbar();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Text selection controls that loosely follows Material design conventions.
|
/// Text selection controls that loosely follows Material design conventions.
|
||||||
|
@ -10125,6 +10125,56 @@ void main() {
|
|||||||
expect(cursorRight, inputWidth - kCaretGap);
|
expect(cursorRight, inputWidth - kCaretGap);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
testWidgets('Text selection menu hides after select all on desktop', (WidgetTester tester) async {
|
||||||
|
final TextEditingController controller = TextEditingController(
|
||||||
|
text: 'Atwater Peel Sherbrooke Bonaventure',
|
||||||
|
);
|
||||||
|
await tester.pumpWidget(
|
||||||
|
MaterialApp(
|
||||||
|
home: Material(
|
||||||
|
child: TextField(
|
||||||
|
controller: controller,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
final String selectAll = defaultTargetPlatform == TargetPlatform.macOS
|
||||||
|
? 'Select All'
|
||||||
|
: 'Select all';
|
||||||
|
|
||||||
|
expect(find.text(selectAll), findsNothing);
|
||||||
|
expect(find.text('Copy'), findsNothing);
|
||||||
|
|
||||||
|
final TestGesture gesture = await tester.startGesture(
|
||||||
|
const Offset(10.0, 0.0) + textOffsetToPosition(tester, controller.text.length),
|
||||||
|
kind: PointerDeviceKind.mouse,
|
||||||
|
buttons: kSecondaryMouseButton,
|
||||||
|
);
|
||||||
|
addTearDown(gesture.removePointer);
|
||||||
|
await tester.pump();
|
||||||
|
await gesture.up();
|
||||||
|
await tester.pumpAndSettle();
|
||||||
|
|
||||||
|
expect(
|
||||||
|
controller.value.selection,
|
||||||
|
TextSelection.collapsed(
|
||||||
|
offset: controller.text.length,
|
||||||
|
affinity: TextAffinity.upstream,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(find.text(selectAll), findsOneWidget);
|
||||||
|
|
||||||
|
await tester.tapAt(tester.getCenter(find.text(selectAll)));
|
||||||
|
|
||||||
|
await tester.pump();
|
||||||
|
expect(find.text(selectAll), findsNothing);
|
||||||
|
expect(find.text('Copy'), findsNothing);
|
||||||
|
},
|
||||||
|
variant: TargetPlatformVariant.desktop(),
|
||||||
|
skip: isContextMenuProvidedByPlatform, // [intended] only applies to platforms where we supply the context menu.
|
||||||
|
);
|
||||||
|
|
||||||
// Regressing test for https://github.com/flutter/flutter/issues/70625
|
// Regressing test for https://github.com/flutter/flutter/issues/70625
|
||||||
testWidgets('TextFields can inherit [FloatingLabelBehaviour] from InputDecorationTheme.', (WidgetTester tester) async {
|
testWidgets('TextFields can inherit [FloatingLabelBehaviour] from InputDecorationTheme.', (WidgetTester tester) async {
|
||||||
final FocusNode focusNode = FocusNode();
|
final FocusNode focusNode = FocusNode();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user