From d5a20a12cec7803dbf3d668397bb56e5bbf14a25 Mon Sep 17 00:00:00 2001 From: flutteractionsbot <154381524+flutteractionsbot@users.noreply.github.com> Date: Tue, 10 Dec 2024 10:55:03 -0800 Subject: [PATCH] [CP-beta]Do not rely on Leader/Follower to position DropdownMenu menu (#159436) This pull request is created by [automatic cherry pick workflow](https://github.com/flutter/flutter/blob/main/docs/releases/Flutter-Cherrypick-Process.md#automatically-creates-a-cherry-pick-request) Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request. ### Issue Link: What is the link to the issue this cherry-pick is addressing? https://github.com/flutter/flutter/issues/157916 and https://github.com/flutter/flutter/issues/158924 ### Changelog Description: Explain this cherry pick in one line that is accessible to most Flutter developers. See [best practices](https://github.com/flutter/flutter/blob/main/docs/releases/Hotfix-Documentation-Best-Practices.md) for examples Restore the previous dropdown menu positioning logic. ### Impact Description: What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)? Does it impact development (ex. flutter doctor crashes when Android Studio is installed), or the shipping production app (the app crashes on launch) DropdownMenu menu is misplaced and can be fully or partially hidden. See https://github.com/flutter/flutter/pull/158930#issuecomment-2492120497 for more context. ### Workaround: Is there a workaround for this issue? No ### Risk: What is the risk level of this cherry-pick? - [x] Low - [ ] Medium - [ ] High ### Test Coverage: Are you confident that your fix is well-tested by automated tests? - [x] Yes - [ ] No ### Validation Steps: What are the steps to validate that this fix works? < Replace with validation steps here > Co-authored-by: Bruno Leroux --- .../lib/src/material/dropdown_menu.dart | 1 - .../test/material/dropdown_menu_test.dart | 41 ------------------- 2 files changed, 42 deletions(-) diff --git a/packages/flutter/lib/src/material/dropdown_menu.dart b/packages/flutter/lib/src/material/dropdown_menu.dart index 14fd7ec1a29..02011274a02 100644 --- a/packages/flutter/lib/src/material/dropdown_menu.dart +++ b/packages/flutter/lib/src/material/dropdown_menu.dart @@ -855,7 +855,6 @@ class _DropdownMenuState extends State> { controller: _controller, menuChildren: menu, crossAxisUnconstrained: false, - layerLink: LayerLink(), builder: (BuildContext context, MenuController controller, Widget? child) { assert(_initialMenu != null); final Widget trailingButton = Padding( diff --git a/packages/flutter/test/material/dropdown_menu_test.dart b/packages/flutter/test/material/dropdown_menu_test.dart index c0d1811bc2b..29db9395e7e 100644 --- a/packages/flutter/test/material/dropdown_menu_test.dart +++ b/packages/flutter/test/material/dropdown_menu_test.dart @@ -3386,47 +3386,6 @@ void main() { expect(controller.offset, 0.0); }); - // Regression test for https://github.com/flutter/flutter/issues/149037. - testWidgets('Dropdown menu follows the text field when keyboard opens', (WidgetTester tester) async { - Widget boilerplate(double bottomInsets) { - return MaterialApp( - home: MediaQuery( - data: MediaQueryData(viewInsets: EdgeInsets.only(bottom: bottomInsets)), - child: Scaffold( - body: Center( - child: DropdownMenu(dropdownMenuEntries: menuChildren), - ), - ), - ), - ); - } - - // Build once without bottom insets and open the menu. - await tester.pumpWidget(boilerplate(0.0)); - await tester.tap(find.byType(TextField).first); - await tester.pump(); - - Finder findMenuPanels() { - return find.byWidgetPredicate((Widget widget) => widget.runtimeType.toString() == '_MenuPanel'); - } - - // Menu vertical position is just under the text field. - expect( - tester.getRect(findMenuPanels()).top, - tester.getRect(find.byType(TextField).first).bottom, - ); - - // Simulate the keyboard opening resizing the view. - await tester.pumpWidget(boilerplate(100.0)); - await tester.pump(); - - // Menu vertical position is just under the text field. - expect( - tester.getRect(findMenuPanels()).top, - tester.getRect(find.byType(TextField).first).bottom, - ); - }); - testWidgets('DropdownMenu with expandedInsets can be aligned', (WidgetTester tester) async { Widget buildMenuAnchor({ AlignmentGeometry alignment = Alignment.topCenter }) { return MaterialApp(