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
03ed3c91
Unverified
Commit
03ed3c91
authored
Mar 02, 2022
by
Markus Aksli
Committed by
GitHub
Mar 02, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reland "Dismiss text selection toolbar with ESC" (#98995)
parent
12bec573
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
0 deletions
+44
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+9
-0
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+35
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
03ed3c91
...
...
@@ -3181,11 +3181,20 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
bringIntoView
(
newSelection
.
extent
);
}
Object
?
_hideToolbarIfVisible
(
DismissIntent
intent
)
{
if
(
_selectionOverlay
?.
toolbarIsVisible
??
false
)
{
hideToolbar
(
false
);
return
null
;
}
return
Actions
.
invoke
(
context
,
intent
);
}
late
final
Map
<
Type
,
Action
<
Intent
>>
_actions
=
<
Type
,
Action
<
Intent
>>{
DoNothingAndStopPropagationTextIntent:
DoNothingAction
(
consumesKey:
false
),
ReplaceTextIntent:
_replaceTextAction
,
UpdateSelectionIntent:
_updateSelectionAction
,
DirectionalFocusIntent:
DirectionalFocusAction
.
forTextField
(),
DismissIntent:
CallbackAction
<
DismissIntent
>(
onInvoke:
_hideToolbarIfVisible
),
// Delete
DeleteCharacterIntent:
_makeOverridable
(
_DeleteTextAction
<
DeleteCharacterIntent
>(
this
,
_characterBoundary
)),
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
03ed3c91
...
...
@@ -1318,6 +1318,41 @@ void main() {
expect
(
find
.
text
(
'Paste'
),
kIsWeb
?
findsNothing
:
findsOneWidget
);
});
testWidgets
(
'can hide toolbar with DismissIntent'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
home:
EditableText
(
backgroundCursorColor:
Colors
.
grey
,
controller:
controller
,
focusNode:
focusNode
,
style:
textStyle
,
cursorColor:
cursorColor
,
selectionControls:
materialTextSelectionControls
,
),
),
);
final
EditableTextState
state
=
tester
.
state
<
EditableTextState
>(
find
.
byType
(
EditableText
));
// Show the toolbar
state
.
renderEditable
.
selectWordsInRange
(
from:
Offset
.
zero
,
cause:
SelectionChangedCause
.
tap
,
);
await
tester
.
pump
();
// On web, we don't let Flutter show the toolbar.
expect
(
state
.
showToolbar
(),
kIsWeb
?
isFalse
:
isTrue
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Paste'
),
kIsWeb
?
findsNothing
:
findsOneWidget
);
// Hide the menu using the DismissIntent.
await
tester
.
sendKeyEvent
(
LogicalKeyboardKey
.
escape
);
await
tester
.
pump
();
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
});
testWidgets
(
'Paste is shown only when there is something to paste'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
MaterialApp
(
...
...
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