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
379c3f46
Commit
379c3f46
authored
Jan 22, 2020
by
shihchanghsiungsonos
Committed by
Dan Field
Jan 22, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the issue of TextSelection could misbehave inside a Nested Overlay (#49257)
parent
a499e05f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
5 deletions
+56
-5
overlay.dart
packages/flutter/lib/src/widgets/overlay.dart
+12
-2
text_selection.dart
packages/flutter/lib/src/widgets/text_selection.dart
+3
-3
text_field_test.dart
packages/flutter/test/material/text_field_test.dart
+41
-0
No files found.
packages/flutter/lib/src/widgets/overlay.dart
View file @
379c3f46
...
...
@@ -242,8 +242,18 @@ class Overlay extends StatefulWidget {
/// ```dart
/// OverlayState overlay = Overlay.of(context);
/// ```
static
OverlayState
of
(
BuildContext
context
,
{
Widget
debugRequiredFor
})
{
final
OverlayState
result
=
context
.
findAncestorStateOfType
<
OverlayState
>();
///
/// If `rootOverlay` is set to true, the state from the furthest instance of
/// this class is given instead. Useful for installing overlay entries
/// above all subsequent instances of [Overlay].
static
OverlayState
of
(
BuildContext
context
,
{
bool
rootOverlay
=
false
,
Widget
debugRequiredFor
,
})
{
final
OverlayState
result
=
rootOverlay
?
context
.
findRootAncestorStateOfType
<
OverlayState
>()
:
context
.
findAncestorStateOfType
<
OverlayState
>();
assert
(()
{
if
(
debugRequiredFor
!=
null
&&
result
==
null
)
{
final
List
<
DiagnosticsNode
>
information
=
<
DiagnosticsNode
>[
...
...
packages/flutter/lib/src/widgets/text_selection.dart
View file @
379c3f46
...
...
@@ -283,7 +283,7 @@ class TextSelectionOverlay {
assert
(
handlesVisible
!=
null
),
_handlesVisible
=
handlesVisible
,
_value
=
value
{
final
OverlayState
overlay
=
Overlay
.
of
(
context
);
final
OverlayState
overlay
=
Overlay
.
of
(
context
,
rootOverlay:
true
);
assert
(
overlay
!=
null
,
'No Overlay widget exists above
$context
.
\n
'
'Usually the Navigator created by WidgetsApp provides the overlay. Perhaps your '
...
...
@@ -410,7 +410,7 @@ class TextSelectionOverlay {
Overlay
.
of
(
context
,
debugRequiredFor:
debugRequiredFor
).
insertAll
(
_handles
);
Overlay
.
of
(
context
,
rootOverlay:
true
,
debugRequiredFor:
debugRequiredFor
).
insertAll
(
_handles
);
}
/// Destroys the handles by removing them from overlay.
...
...
@@ -426,7 +426,7 @@ class TextSelectionOverlay {
void
showToolbar
()
{
assert
(
_toolbar
==
null
);
_toolbar
=
OverlayEntry
(
builder:
_buildToolbar
);
Overlay
.
of
(
context
,
debugRequiredFor:
debugRequiredFor
).
insert
(
_toolbar
);
Overlay
.
of
(
context
,
rootOverlay:
true
,
debugRequiredFor:
debugRequiredFor
).
insert
(
_toolbar
);
_toolbarController
.
forward
(
from:
0.0
);
}
...
...
packages/flutter/test/material/text_field_test.dart
View file @
379c3f46
...
...
@@ -7432,4 +7432,45 @@ void main() {
expect
(
textFieldSize1
,
equals
(
textFieldSize2
));
});
testWidgets
(
'The selection menu displays in an Overlay without error'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for
// https://github.com/flutter/flutter/issues/43787
final
TextEditingController
controller
=
TextEditingController
(
text:
'This is a test that shows some odd behavior with Text Selection!'
,
);
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Container
(
color:
Colors
.
grey
,
child:
Center
(
child:
Container
(
color:
Colors
.
red
,
width:
300
,
height:
600
,
child:
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
builder:
(
BuildContext
context
)
=>
Center
(
child:
TextField
(
controller:
controller
,
),
),
)
],
),
),
),
),
),
));
await
_showSelectionMenuAt
(
tester
,
controller
,
controller
.
text
.
indexOf
(
'test'
));
await
tester
.
pumpAndSettle
();
expect
(
tester
.
takeException
(),
isNull
);
},
);
}
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