Unverified Commit 4a1002e2 authored by Jan Kuß's avatar Jan Kuß Committed by GitHub

Fix selection toolbar not showing on drag end (#121110)

parent 1fb2158e
......@@ -537,6 +537,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
} else {
_selectionOverlay!.hideMagnifier();
_selectionOverlay!.showToolbar(
context: context,
contextMenuBuilder: (BuildContext context) {
return widget.contextMenuBuilder!(context, this);
},
......
......@@ -129,4 +129,53 @@ void main() {
expect(content, isNotNull);
expect(content!.plainText, 'How');
});
testWidgets('stopping drag of end handle will show the toolbar', (WidgetTester tester) async {
// Regression test for https://github.com/flutter/flutter/issues/119314
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Padding(
padding: const EdgeInsets.only(top: 64),
child: Column(
children: <Widget>[
const Text('How are you?'),
SelectionArea(
focusNode: FocusNode(),
child: const Text('Good, and you?'),
),
const Text('Fine, thank you.'),
],
),
),
),
),
);
final RenderParagraph paragraph2 = tester.renderObject<RenderParagraph>(find.descendant(of: find.text('Good, and you?'), matching: find.byType(RichText)));
final TestGesture gesture = await tester.startGesture(textOffsetToPosition(paragraph2, 7)); // at the 'a'
addTearDown(gesture.removePointer);
await tester.pump(const Duration(milliseconds: 500));
await gesture.up();
final List<TextBox> boxes = paragraph2.getBoxesForSelection(paragraph2.selections[0]);
expect(boxes.length, 1);
// There is a selection now.
// We check the presence of the copy button to make sure the selection toolbar
// is showing.
expect(find.text('Copy'), findsOneWidget);
// This is the position of the selection handle displayed at the end.
final Offset handlePos = paragraph2.localToGlobal(boxes[0].toRect().bottomRight);
await gesture.down(handlePos);
await gesture.moveTo(textOffsetToPosition(paragraph2, 11) + Offset(0, paragraph2.size.height / 2));
await tester.pump();
await gesture.up();
await tester.pump();
// After lifting the finger up, the selection toolbar should be showing again.
expect(find.text('Copy'), findsOneWidget);
},
variant: TargetPlatformVariant.all(),
skip: kIsWeb, // [intended]
);
}
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