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
ce4f15cd
Unverified
Commit
ce4f15cd
authored
Jun 10, 2019
by
Justin McCandless
Committed by
GitHub
Jun 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Toggle toolbar exception fix (#34055)
Stop a text editing error from happening
parent
1157e674
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
12 deletions
+13
-12
text_field.dart
packages/flutter/lib/src/material/text_field.dart
+3
-3
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+4
-3
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+6
-6
No files found.
packages/flutter/lib/src/material/text_field.dart
View file @
ce4f15cd
...
@@ -749,7 +749,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
...
@@ -749,7 +749,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
cause:
SelectionChangedCause
.
forcePress
,
cause:
SelectionChangedCause
.
forcePress
,
);
);
if
(
_shouldShowSelectionToolbar
)
{
if
(
_shouldShowSelectionToolbar
)
{
_editableTextKey
.
currentState
.
toggle
Toolbar
();
_editableTextKey
.
currentState
.
show
Toolbar
();
}
}
}
}
}
}
...
@@ -819,7 +819,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
...
@@ -819,7 +819,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
void
_handleSingleLongTapEnd
(
LongPressEndDetails
details
)
{
void
_handleSingleLongTapEnd
(
LongPressEndDetails
details
)
{
if
(
widget
.
selectionEnabled
)
{
if
(
widget
.
selectionEnabled
)
{
if
(
_shouldShowSelectionToolbar
)
if
(
_shouldShowSelectionToolbar
)
_editableTextKey
.
currentState
.
toggle
Toolbar
();
_editableTextKey
.
currentState
.
show
Toolbar
();
}
}
}
}
...
@@ -827,7 +827,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
...
@@ -827,7 +827,7 @@ class _TextFieldState extends State<TextField> with AutomaticKeepAliveClientMixi
if
(
widget
.
selectionEnabled
)
{
if
(
widget
.
selectionEnabled
)
{
_renderEditable
.
selectWord
(
cause:
SelectionChangedCause
.
doubleTap
);
_renderEditable
.
selectWord
(
cause:
SelectionChangedCause
.
doubleTap
);
if
(
_shouldShowSelectionToolbar
)
{
if
(
_shouldShowSelectionToolbar
)
{
_editableText
.
toggle
Toolbar
();
_editableText
.
show
Toolbar
();
}
}
}
}
}
}
...
...
packages/flutter/lib/src/widgets/editable_text.dart
View file @
ce4f15cd
...
@@ -1482,11 +1482,12 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
...
@@ -1482,11 +1482,12 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
/// Shows the selection toolbar at the location of the current cursor.
/// Shows the selection toolbar at the location of the current cursor.
///
///
/// Returns `false` if a toolbar couldn't be shown
such as when no text
/// Returns `false` if a toolbar couldn't be shown
, such as when the toolbar
/// selection currently exists.
///
is already shown, or when no text
selection currently exists.
bool
showToolbar
()
{
bool
showToolbar
()
{
if
(
_selectionOverlay
==
null
)
if
(
_selectionOverlay
==
null
||
_selectionOverlay
.
toolbarIsVisible
)
{
return
false
;
return
false
;
}
_selectionOverlay
.
showToolbar
();
_selectionOverlay
.
showToolbar
();
return
true
;
return
true
;
...
...
packages/flutter/test/material/text_field_test.dart
View file @
ce4f15cd
...
@@ -5221,7 +5221,7 @@ void main() {
...
@@ -5221,7 +5221,7 @@ void main() {
);
);
testWidgets
(
testWidgets
(
'double double tap
toggles
selection menu'
,
'double double tap
just shows the
selection menu'
,
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
final
TextEditingController
controller
=
TextEditingController
(
text:
''
,
text:
''
,
...
@@ -5245,17 +5245,17 @@ void main() {
...
@@ -5245,17 +5245,17 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'PASTE'
),
findsOneWidget
);
expect
(
find
.
text
(
'PASTE'
),
findsOneWidget
);
// Double tap again
hides the selection menu
.
// Double tap again
keeps the selection menu visible
.
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
0
));
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
0
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
await
tester
.
pump
(
const
Duration
(
milliseconds:
50
));
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
0
));
await
tester
.
tapAt
(
textOffsetToPosition
(
tester
,
0
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'PASTE'
),
finds
NWidgets
(
0
)
);
expect
(
find
.
text
(
'PASTE'
),
finds
OneWidget
);
},
},
);
);
testWidgets
(
testWidgets
(
'double long press
toggles
selection menu'
,
'double long press
just shows the
selection menu'
,
(
WidgetTester
tester
)
async
{
(
WidgetTester
tester
)
async
{
final
TextEditingController
controller
=
TextEditingController
(
final
TextEditingController
controller
=
TextEditingController
(
text:
''
,
text:
''
,
...
@@ -5277,10 +5277,10 @@ void main() {
...
@@ -5277,10 +5277,10 @@ void main() {
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'PASTE'
),
findsOneWidget
);
expect
(
find
.
text
(
'PASTE'
),
findsOneWidget
);
//
Double tap again hides the selection menu
.
//
Long press again keeps the selection menu visible
.
await
tester
.
longPressAt
(
textOffsetToPosition
(
tester
,
0
));
await
tester
.
longPressAt
(
textOffsetToPosition
(
tester
,
0
));
await
tester
.
pump
();
await
tester
.
pump
();
expect
(
find
.
text
(
'PASTE'
),
finds
NWidgets
(
0
)
);
expect
(
find
.
text
(
'PASTE'
),
finds
OneWidget
);
},
},
);
);
...
...
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