Skip to content

Commit

Permalink
Toolbar should re-appear on drag end (#125165)
Browse files Browse the repository at this point in the history
#125151 introduced the magnifier on touch drag gestures, but when showing the magnifier the toolbar is implicitly hidden, this change makes the toolbar re-appear on drag end for double tap + drag.
  • Loading branch information
Renzo-Olivares authored Apr 20, 2023
1 parent dcfd35f commit 01b4dd5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/flutter/lib/src/widgets/text_selection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,10 @@ class TextSelectionGestureDetectorBuilder {
final bool isShiftPressed = _containsShift(details.keysPressedOnDown);
_dragBeganOnPreviousSelection = null;

if (_shouldShowSelectionToolbar && _TextSelectionGestureDetectorState._getEffectiveConsecutiveTapCount(details.consecutiveTapCount) == 2) {
editableText.showToolbar();
}

if (isShiftPressed) {
_dragStartSelection = null;
}
Expand Down
7 changes: 7 additions & 0 deletions packages/flutter/test/cupertino/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2245,8 +2245,15 @@ void main() {
await gesture.moveTo(hPos);
await tester.pumpAndSettle();

// Toolbar should be hidden during a drag.
expect(find.byType(CupertinoButton), findsNothing);
expect(controller.selection.baseOffset, testValue.indexOf('d'));
expect(controller.selection.extentOffset, testValue.indexOf('i') + 1);

// Toolbar should re-appear after a drag.
await gesture.up();
await tester.pump();
expect(find.byType(CupertinoButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(4));
},
);

Expand Down
7 changes: 7 additions & 0 deletions packages/flutter/test/material/text_field_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9396,8 +9396,15 @@ void main() {
await gesture.moveTo(hPos);
await tester.pumpAndSettle();

// Toolbar should be hidden during a drag.
expect(find.byType(TextButton), findsNothing);
expect(controller.selection.baseOffset, testValue.indexOf('d'));
expect(controller.selection.extentOffset, testValue.indexOf('i') + 1);

// Toolbar should re-appear after a drag.
await gesture.up();
await tester.pump();
expect(find.byType(TextButton), isContextMenuProvidedByPlatform ? findsNothing : findsNWidgets(4));
},
);

Expand Down

0 comments on commit 01b4dd5

Please sign in to comment.