mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Selection menu not showing when selection is 0,0 (#49000)
This commit is contained in:
parent
f013b25b9c
commit
c61e55ad6b
@ -409,8 +409,14 @@ class RenderEditable extends RenderBox with RelayoutWhenSystemFontsChangeMixin {
|
||||
) {
|
||||
// Changes made by the keyboard can sometimes be "out of band" for listening
|
||||
// components, so always send those events, even if we didn't think it
|
||||
// changed.
|
||||
if (nextSelection == selection && cause != SelectionChangedCause.keyboard) {
|
||||
// changed. Also, focusing an empty field is sent as a selection change even
|
||||
// if the selection offset didn't change.
|
||||
final bool focusingEmpty = nextSelection.baseOffset == 0
|
||||
&& nextSelection.extentOffset == 0
|
||||
&& !hasFocus;
|
||||
if (nextSelection == selection
|
||||
&& cause != SelectionChangedCause.keyboard
|
||||
&& !focusingEmpty) {
|
||||
return;
|
||||
}
|
||||
if (onSelectionChanged != null) {
|
||||
|
@ -857,6 +857,27 @@ void main() {
|
||||
expect(handle.opacity.value, equals(1.0));
|
||||
});
|
||||
|
||||
|
||||
testWidgets('Long pressing a field with selection 0,0 shows the selection menu', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(overlay(
|
||||
child: TextField(
|
||||
controller: TextEditingController.fromValue(
|
||||
const TextEditingValue(
|
||||
selection: TextSelection(baseOffset: 0, extentOffset: 0),
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
expect(find.text('PASTE'), findsNothing);
|
||||
|
||||
final Offset emptyPos = textOffsetToPosition(tester, 0);
|
||||
await tester.longPressAt(emptyPos, pointer: 7);
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('PASTE'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Entering text hides selection handle caret', (WidgetTester tester) async {
|
||||
final TextEditingController controller = TextEditingController();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user