Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
6ffcc9e5
Unverified
Commit
6ffcc9e5
authored
May 12, 2023
by
Justin McCandless
Committed by
GitHub
May 12, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide the context menu on tap down (#126295)
Desktop text selection toolbar no longer flashes before closing.
parent
15a7e073
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
3 deletions
+97
-3
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+5
-3
text_field_test.dart
packages/flutter/test/cupertino/text_field_test.dart
+45
-0
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+47
-0
No files found.
packages/flutter/lib/src/widgets/text_selection.dart
View file @
6ffcc9e5
...
@@ -2108,10 +2108,13 @@ class TextSelectionGestureDetectorBuilder {
...
@@ -2108,10 +2108,13 @@ class TextSelectionGestureDetectorBuilder {
switch
(
defaultTargetPlatform
)
{
switch
(
defaultTargetPlatform
)
{
case
TargetPlatform
.
android
:
case
TargetPlatform
.
android
:
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
fuchsia
:
// On mobile platforms the selection is set on tap up.
editableText
.
hideToolbar
(
false
);
case
TargetPlatform
.
iOS
:
case
TargetPlatform
.
iOS
:
// On mobile platforms the selection is set on tap up.
// On mobile platforms the selection is set on tap up.
break
;
break
;
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
macOS
:
editableText
.
hideToolbar
();
// On macOS, a shift-tapped unfocused field expands from 0, not from the
// On macOS, a shift-tapped unfocused field expands from 0, not from the
// previous selection.
// previous selection.
if
(
isShiftPressedValid
)
{
if
(
isShiftPressedValid
)
{
...
@@ -2132,6 +2135,7 @@ class TextSelectionGestureDetectorBuilder {
...
@@ -2132,6 +2135,7 @@ class TextSelectionGestureDetectorBuilder {
renderEditable
.
selectPosition
(
cause:
SelectionChangedCause
.
tap
);
renderEditable
.
selectPosition
(
cause:
SelectionChangedCause
.
tap
);
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
windows
:
case
TargetPlatform
.
windows
:
editableText
.
hideToolbar
();
if
(
isShiftPressedValid
)
{
if
(
isShiftPressedValid
)
{
_extendSelection
(
details
.
globalPosition
,
SelectionChangedCause
.
tap
);
_extendSelection
(
details
.
globalPosition
,
SelectionChangedCause
.
tap
);
return
;
return
;
...
@@ -2206,10 +2210,9 @@ class TextSelectionGestureDetectorBuilder {
...
@@ -2206,10 +2210,9 @@ class TextSelectionGestureDetectorBuilder {
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
linux
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
macOS
:
case
TargetPlatform
.
windows
:
case
TargetPlatform
.
windows
:
editableText
.
hideToolbar
()
;
break
;
// On desktop platforms the selection is set on tap down.
// On desktop platforms the selection is set on tap down.
case
TargetPlatform
.
android
:
case
TargetPlatform
.
android
:
editableText
.
hideToolbar
();
if
(
isShiftPressedValid
)
{
if
(
isShiftPressedValid
)
{
_extendSelection
(
details
.
globalPosition
,
SelectionChangedCause
.
tap
);
_extendSelection
(
details
.
globalPosition
,
SelectionChangedCause
.
tap
);
return
;
return
;
...
@@ -2217,7 +2220,6 @@ class TextSelectionGestureDetectorBuilder {
...
@@ -2217,7 +2220,6 @@ class TextSelectionGestureDetectorBuilder {
renderEditable
.
selectPosition
(
cause:
SelectionChangedCause
.
tap
);
renderEditable
.
selectPosition
(
cause:
SelectionChangedCause
.
tap
);
editableText
.
showSpellCheckSuggestionsToolbar
();
editableText
.
showSpellCheckSuggestionsToolbar
();
case
TargetPlatform
.
fuchsia
:
case
TargetPlatform
.
fuchsia
:
editableText
.
hideToolbar
();
if
(
isShiftPressedValid
)
{
if
(
isShiftPressedValid
)
{
_extendSelection
(
details
.
globalPosition
,
SelectionChangedCause
.
tap
);
_extendSelection
(
details
.
globalPosition
,
SelectionChangedCause
.
tap
);
return
;
return
;
...
...
packages/flutter/test/cupertino/text_field_test.dart
View file @
6ffcc9e5
...
@@ -9513,4 +9513,49 @@ void main() {
...
@@ -9513,4 +9513,49 @@ void main() {
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
}),
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
}),
skip:
kIsWeb
,
// [intended]
skip:
kIsWeb
,
// [intended]
);
);
testWidgets
(
'text selection toolbar is hidden on tap down'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'blah1 blah2'
,
);
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
CupertinoTextField
(
controller:
controller
,
),
),
),
);
expect
(
find
.
byType
(
CupertinoAdaptiveTextSelectionToolbar
),
findsNothing
);
TestGesture
gesture
=
await
tester
.
startGesture
(
textOffsetToPosition
(
tester
,
8
),
kind:
PointerDeviceKind
.
mouse
,
buttons:
kSecondaryMouseButton
,
);
await
tester
.
pump
();
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
CupertinoAdaptiveTextSelectionToolbar
),
findsOneWidget
);
gesture
=
await
tester
.
startGesture
(
textOffsetToPosition
(
tester
,
2
),
kind:
PointerDeviceKind
.
mouse
,
);
await
tester
.
pump
();
// After the gesture is down but not up, the toolbar is already gone.
expect
(
find
.
byType
(
CupertinoAdaptiveTextSelectionToolbar
),
findsNothing
);
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
CupertinoAdaptiveTextSelectionToolbar
),
findsNothing
);
},
skip:
isContextMenuProvidedByPlatform
,
// [intended] only applies to platforms where we supply the context menu.
variant:
TargetPlatformVariant
.
all
(
excluding:
<
TargetPlatform
>{
TargetPlatform
.
iOS
}),
);
}
}
packages/flutter/test/material/text_field_test.dart
View file @
6ffcc9e5
...
@@ -16315,6 +16315,53 @@ void main() {
...
@@ -16315,6 +16315,53 @@ void main() {
expectedConfiguration
.
spellCheckSuggestionsToolbarBuilder
,
expectedConfiguration
.
spellCheckSuggestionsToolbarBuilder
,
);
);
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
android
,
TargetPlatform
.
iOS
}));
},
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
android
,
TargetPlatform
.
iOS
}));
testWidgets
(
'text selection toolbar is hidden on tap down'
,
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
text:
'blah1 blah2'
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Center
(
child:
TextField
(
controller:
controller
,
),
),
),
),
);
expect
(
find
.
byType
(
AdaptiveTextSelectionToolbar
),
findsNothing
);
TestGesture
gesture
=
await
tester
.
startGesture
(
textOffsetToPosition
(
tester
,
8
),
kind:
PointerDeviceKind
.
mouse
,
buttons:
kSecondaryMouseButton
,
);
await
tester
.
pump
();
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
AdaptiveTextSelectionToolbar
),
findsOneWidget
);
gesture
=
await
tester
.
startGesture
(
textOffsetToPosition
(
tester
,
2
),
kind:
PointerDeviceKind
.
mouse
,
);
await
tester
.
pump
();
// After the gesture is down but not up, the toolbar is already gone.
expect
(
find
.
byType
(
AdaptiveTextSelectionToolbar
),
findsNothing
);
await
gesture
.
up
();
await
tester
.
pumpAndSettle
();
expect
(
find
.
byType
(
AdaptiveTextSelectionToolbar
),
findsNothing
);
},
skip:
isContextMenuProvidedByPlatform
,
// [intended] only applies to platforms where we supply the context menu.
variant:
TargetPlatformVariant
.
all
(
excluding:
<
TargetPlatform
>{
TargetPlatform
.
iOS
}),
);
}
}
/// A Simple widget for testing the obscure text.
/// A Simple widget for testing the obscure text.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment