Skip to content

Commit 773b42f

Browse files
authored
Do not rely on Leader/Follower to position DropdownMenu menu (#158930)
## Description This PR removes `DropdownMenu` usage of Leader/Follower. Leader/Follower positioning was introduced in flutter/flutter#154667 which uses Leader/Follower approach to fix some weird positioning issues (such as flutter/flutter#149037). Unfortunately, it also introduces some regressions, see: - flutter/flutter#157916 - flutter/flutter#158924 Because flutter/flutter#154667 is already included in the beta channel, cherry-picking this PR should be considered. ## Context This PR is not a full revert and keeps Leader/Follower usage in `MenuAnchor` because this usage is optional and doesn't cause any regression. There are some ongoing work which might fix or mitigate this problem: - flutter/flutter#157921 - flutter/flutter#158255 ## Related Issue Fixes flutter/flutter#157916 Fixes flutter/flutter#158924 Reopens flutter/flutter#123395 Reopens flutter/flutter#149037 Reopens flutter/flutter#151856
1 parent d39c353 commit 773b42f

2 files changed

Lines changed: 0 additions & 42 deletions

File tree

packages/flutter/lib/src/material/dropdown_menu.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,6 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
902902
controller: _controller,
903903
menuChildren: menu,
904904
crossAxisUnconstrained: false,
905-
layerLink: LayerLink(),
906905
builder: (BuildContext context, MenuController controller, Widget? child) {
907906
assert(_initialMenu != null);
908907
final Widget trailingButton = Padding(

packages/flutter/test/material/dropdown_menu_test.dart

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3366,47 +3366,6 @@ void main() {
33663366
expect(controller.offset, 0.0);
33673367
});
33683368

3369-
// Regression test for https://github.com/flutter/flutter/issues/149037.
3370-
testWidgets('Dropdown menu follows the text field when keyboard opens', (WidgetTester tester) async {
3371-
Widget boilerplate(double bottomInsets) {
3372-
return MaterialApp(
3373-
home: MediaQuery(
3374-
data: MediaQueryData(viewInsets: EdgeInsets.only(bottom: bottomInsets)),
3375-
child: Scaffold(
3376-
body: Center(
3377-
child: DropdownMenu<TestMenu>(dropdownMenuEntries: menuChildren),
3378-
),
3379-
),
3380-
),
3381-
);
3382-
}
3383-
3384-
// Build once without bottom insets and open the menu.
3385-
await tester.pumpWidget(boilerplate(0.0));
3386-
await tester.tap(find.byType(TextField).first);
3387-
await tester.pump();
3388-
3389-
Finder findMenuPanels() {
3390-
return find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_MenuPanel');
3391-
}
3392-
3393-
// Menu vertical position is just under the text field.
3394-
expect(
3395-
tester.getRect(findMenuPanels()).top,
3396-
tester.getRect(find.byType(TextField).first).bottom,
3397-
);
3398-
3399-
// Simulate the keyboard opening resizing the view.
3400-
await tester.pumpWidget(boilerplate(100.0));
3401-
await tester.pump();
3402-
3403-
// Menu vertical position is just under the text field.
3404-
expect(
3405-
tester.getRect(findMenuPanels()).top,
3406-
tester.getRect(find.byType(TextField).first).bottom,
3407-
);
3408-
});
3409-
34103369
testWidgets('DropdownMenu with expandedInsets can be aligned', (WidgetTester tester) async {
34113370
Widget buildMenuAnchor({ AlignmentGeometry alignment = Alignment.topCenter }) {
34123371
return MaterialApp(

0 commit comments

Comments
 (0)