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
3e069a43
Unverified
Commit
3e069a43
authored
4 years ago
by
Sergey Solodukhin
Committed by
GitHub
4 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix issue #55400 PopupMenuButton positions menu incorrectly with nest… (#65832)
parent
7ce0dce2
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
84 additions
and
1 deletion
+84
-1
popup_menu.dart
packages/flutter/lib/src/material/popup_menu.dart
+1
-1
popup_menu_test.dart
packages/flutter/test/material/popup_menu_test.dart
+83
-0
No files found.
packages/flutter/lib/src/material/popup_menu.dart
View file @
3e069a43
...
...
@@ -1077,7 +1077,7 @@ class PopupMenuButtonState<T> extends State<PopupMenuButton<T>> {
void
showButtonMenu
()
{
final
PopupMenuThemeData
popupMenuTheme
=
PopupMenuTheme
.
of
(
context
);
final
RenderBox
button
=
context
.
findRenderObject
()!
as
RenderBox
;
final
RenderBox
overlay
=
Overlay
.
of
(
context
)
!.
context
.
findRenderObject
()!
as
RenderBox
;
final
RenderBox
overlay
=
Navigator
.
of
(
context
)!.
overlay
!.
context
.
findRenderObject
()!
as
RenderBox
;
final
RelativeRect
position
=
RelativeRect
.
fromRect
(
Rect
.
fromPoints
(
button
.
localToGlobal
(
widget
.
offset
,
ancestor:
overlay
),
...
...
This diff is collapsed.
Click to expand it.
packages/flutter/test/material/popup_menu_test.dart
View file @
3e069a43
...
...
@@ -634,6 +634,89 @@ void main() {
await
testPositioningDownThenUp
(
tester
,
TextDirection
.
rtl
,
Alignment
.
bottomCenter
,
TextDirection
.
rtl
,
const
Rect
.
fromLTWH
(
450.0
,
500.0
,
0.0
,
0.0
));
});
testWidgets
(
'PopupMenu positioning inside nested Overlay'
,
(
WidgetTester
tester
)
async
{
final
Key
buttonKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Example'
)),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Overlay
(
initialEntries:
<
OverlayEntry
>[
OverlayEntry
(
builder:
(
_
)
=>
Center
(
child:
PopupMenuButton
<
int
>(
key:
buttonKey
,
itemBuilder:
(
_
)
=>
<
PopupMenuItem
<
int
>>[
const
PopupMenuItem
<
int
>(
value:
1
,
child:
Text
(
'Item 1'
)),
const
PopupMenuItem
<
int
>(
value:
2
,
child:
Text
(
'Item 2'
)),
],
child:
const
Text
(
'Show Menu'
),
),
),
),
],
),
),
),
),
);
final
Finder
buttonFinder
=
find
.
byKey
(
buttonKey
);
final
Finder
popupFinder
=
find
.
bySemanticsLabel
(
'Popup menu'
);
await
tester
.
tap
(
buttonFinder
);
await
tester
.
pumpAndSettle
();
final
Offset
buttonTopLeft
=
tester
.
getTopLeft
(
buttonFinder
);
expect
(
tester
.
getTopLeft
(
popupFinder
),
buttonTopLeft
);
});
testWidgets
(
'PopupMenu positioning inside nested Navigator'
,
(
WidgetTester
tester
)
async
{
final
Key
buttonKey
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
appBar:
AppBar
(
title:
const
Text
(
'Example'
)),
body:
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Navigator
(
onGenerateRoute:
(
RouteSettings
settings
)
{
return
MaterialPageRoute
<
dynamic
>(
builder:
(
BuildContext
context
)
{
return
Padding
(
padding:
const
EdgeInsets
.
all
(
8.0
),
child:
Center
(
child:
PopupMenuButton
<
int
>(
key:
buttonKey
,
itemBuilder:
(
_
)
=>
<
PopupMenuItem
<
int
>>[
const
PopupMenuItem
<
int
>(
value:
1
,
child:
Text
(
'Item 1'
)),
const
PopupMenuItem
<
int
>(
value:
2
,
child:
Text
(
'Item 2'
)),
],
child:
const
Text
(
'Show Menu'
),
),
),
);
},
);
},
),
),
),
),
);
final
Finder
buttonFinder
=
find
.
byKey
(
buttonKey
);
final
Finder
popupFinder
=
find
.
bySemanticsLabel
(
'Popup menu'
);
await
tester
.
tap
(
buttonFinder
);
await
tester
.
pumpAndSettle
();
final
Offset
buttonTopLeft
=
tester
.
getTopLeft
(
buttonFinder
);
expect
(
tester
.
getTopLeft
(
popupFinder
),
buttonTopLeft
);
});
testWidgets
(
'PopupMenu removes MediaQuery padding'
,
(
WidgetTester
tester
)
async
{
late
BuildContext
popupContext
;
...
...
This diff is collapsed.
Click to expand it.
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