Selection area should move selection word by word on a long press drag (#132518)
On native iOS and Android when long pressing and then dragging the selection expands word by word. Before this change `SelectionArea` expanded the selection character by character on a long press drag. Fixes #104603
This commit is contained in:
parent
0a10359f6a
commit
9a39a5d697
@ -529,7 +529,7 @@ class SelectableRegionState extends State<SelectableRegion> with TextSelectionDe
|
||||
}
|
||||
|
||||
void _handleTouchLongPressMoveUpdate(LongPressMoveUpdateDetails details) {
|
||||
_selectEndTo(offset: details.globalPosition);
|
||||
_selectEndTo(offset: details.globalPosition, textGranularity: TextGranularity.word);
|
||||
}
|
||||
|
||||
void _handleTouchLongPressEnd(LongPressEndDetails details) {
|
||||
|
@ -338,6 +338,7 @@ void main() {
|
||||
expect(renderSelectionSpy.events[0].type, SelectionEventType.endEdgeUpdate);
|
||||
final SelectionEdgeUpdateEvent edgeEvent = renderSelectionSpy.events[0] as SelectionEdgeUpdateEvent;
|
||||
expect(edgeEvent.globalPosition, const Offset(200.0, 50.0));
|
||||
expect(edgeEvent.granularity, TextGranularity.word);
|
||||
});
|
||||
|
||||
testWidgets(
|
||||
@ -1656,7 +1657,7 @@ void main() {
|
||||
await gesture.up();
|
||||
}, skip: isBrowser); // https://github.com/flutter/flutter/issues/61020
|
||||
|
||||
testWidgets('long press and drag touch selection', (WidgetTester tester) async {
|
||||
testWidgets('long press and drag touch moves selection word by word', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
home: SelectableRegion(
|
||||
@ -1681,9 +1682,9 @@ void main() {
|
||||
expect(paragraph1.selections[0], const TextSelection(baseOffset: 4, extentOffset: 7));
|
||||
|
||||
final RenderParagraph paragraph2 = tester.renderObject<RenderParagraph>(find.descendant(of: find.text('Good, and you?'), matching: find.byType(RichText)));
|
||||
await gesture.moveTo(textOffsetToPosition(paragraph2, 5));
|
||||
await gesture.moveTo(textOffsetToPosition(paragraph2, 7));
|
||||
expect(paragraph1.selections[0], const TextSelection(baseOffset: 4, extentOffset: 12));
|
||||
expect(paragraph2.selections[0], const TextSelection(baseOffset: 0, extentOffset: 5));
|
||||
expect(paragraph2.selections[0], const TextSelection(baseOffset: 0, extentOffset: 9));
|
||||
await gesture.up();
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user