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
b05741cb
Unverified
Commit
b05741cb
authored
May 25, 2022
by
Markus Aksli
Committed by
GitHub
May 25, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hide the text selection toolbar on mobile when orientation changes (#103512)
parent
5a919673
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
0 deletions
+70
-0
editable_text.dart
packages/flutter/lib/src/widgets/editable_text.dart
+22
-0
editable_text_test.dart
packages/flutter/test/widgets/editable_text_test.dart
+48
-0
No files found.
packages/flutter/lib/src/widgets/editable_text.dart
View file @
b05741cb
...
...
@@ -1646,6 +1646,8 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
AnimationController
?
_floatingCursorResetController
;
Orientation
?
_lastOrientation
;
@override
bool
get
wantKeepAlive
=>
widget
.
focusNode
.
hasFocus
;
...
...
@@ -1850,6 +1852,26 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
_cursorTimer
=
null
;
}
}
if
(
defaultTargetPlatform
!=
TargetPlatform
.
iOS
&&
defaultTargetPlatform
!=
TargetPlatform
.
android
)
{
return
;
}
// Hide the text selection toolbar on mobile when orientation changes.
final
Orientation
orientation
=
MediaQuery
.
of
(
context
).
orientation
;
if
(
_lastOrientation
==
null
)
{
_lastOrientation
=
orientation
;
return
;
}
if
(
orientation
!=
_lastOrientation
)
{
_lastOrientation
=
orientation
;
if
(
defaultTargetPlatform
==
TargetPlatform
.
iOS
)
{
hideToolbar
(
false
);
}
if
(
defaultTargetPlatform
==
TargetPlatform
.
android
)
{
hideToolbar
();
}
}
}
@override
...
...
packages/flutter/test/widgets/editable_text_test.dart
View file @
b05741cb
...
...
@@ -1503,6 +1503,54 @@ void main() {
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
});
testWidgets
(
'toolbar hidden on mobile when orientation changes'
,
(
WidgetTester
tester
)
async
{
addTearDown
(
tester
.
binding
.
window
.
clearPhysicalSizeTestValue
);
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
();
expect
(
state
.
showToolbar
(),
true
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Paste'
),
findsOneWidget
);
// Hide the menu by changing orientation.
tester
.
binding
.
window
.
physicalSizeTestValue
=
const
Size
(
1800.0
,
2400.0
);
await
tester
.
pumpAndSettle
();
expect
(
find
.
text
(
'Paste'
),
findsNothing
);
// Handles should be hidden as well on Android
expect
(
find
.
descendant
(
of:
find
.
byType
(
CompositedTransformFollower
),
matching:
find
.
byType
(
Padding
),
),
defaultTargetPlatform
==
TargetPlatform
.
android
?
findsNothing
:
findsOneWidget
,
);
// On web, we don't show the Flutter toolbar and instead rely on the browser
// toolbar. Until we change that, this test should remain skipped.
},
skip:
kIsWeb
,
variant:
const
TargetPlatformVariant
(<
TargetPlatform
>{
TargetPlatform
.
iOS
,
TargetPlatform
.
android
}));
// [intended]
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