mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[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 <bruno.leroux@gmail.com>
This commit is contained in:
parent
32644266fa
commit
d5a20a12ce
@ -855,7 +855,6 @@ class _DropdownMenuState<T> extends State<DropdownMenu<T>> {
|
||||
controller: _controller,
|
||||
menuChildren: menu,
|
||||
crossAxisUnconstrained: false,
|
||||
layerLink: LayerLink(),
|
||||
builder: (BuildContext context, MenuController controller, Widget? child) {
|
||||
assert(_initialMenu != null);
|
||||
final Widget trailingButton = Padding(
|
||||
|
||||
@ -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<TestMenu>(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(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user