Implement SelectionArea single click/tap gestures (#132682)
This change collapses the selection at the clicked/tapped location on single click down for desktop platforms, and on single click/tap up for mobile platforms to match native. This is a change from how `SelectionArea` previously worked. Before this change a single click down would clear the selection. From observing a native browser it looks like when tapping on static text the selection is not cleared but collapsed. A user can still attain the selection from static text using the `window.getSelection` API. https://jsfiddle.net/juepasn3/11/ You can try this demo out here to observe this behavior yourself. When clicking on static text the selection will change. This change also allows `Paragraph.selections` to return selections that are collapsed. This for testing purposes to confirm where the selection has been collapsed. Partially fixes: #129583
This commit is contained in:
@@ -24,6 +24,9 @@ void main() {
|
||||
|
||||
// Right clicking the Text in the SelectionArea shows the custom context
|
||||
// menu.
|
||||
final TestGesture primaryMouseButtonGesture = await tester.createGesture(
|
||||
kind: PointerDeviceKind.mouse,
|
||||
);
|
||||
final TestGesture gesture = await tester.startGesture(
|
||||
tester.getCenter(find.text(example.text)),
|
||||
kind: PointerDeviceKind.mouse,
|
||||
@@ -37,7 +40,9 @@ void main() {
|
||||
expect(find.text('Print'), findsOneWidget);
|
||||
|
||||
// Tap to dismiss.
|
||||
await tester.tapAt(tester.getCenter(find.byType(Scaffold)));
|
||||
await primaryMouseButtonGesture.down(tester.getCenter(find.byType(Scaffold)));
|
||||
await tester.pump();
|
||||
await primaryMouseButtonGesture.up();
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.byType(AdaptiveTextSelectionToolbar), findsNothing);
|
||||
|
||||
Reference in New Issue
Block a user