fix a dropdown button menu position bug #89199
Conversation
menuTop = math.min(buttonTop, topLimit); | ||
menuBottom = menuTop + menuHeight; |
xu-baolin
Aug 31, 2021
Author
Member
This is a bug and I add an assertion to check this at line 580
This is a bug and I add an assertion to check this at line 580
Ready for review now. |
@@ -516,7 +516,10 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> { | |||
// selected item is aligned with the button's vertical center, as far as | |||
// that's possible given availableHeight. | |||
_MenuLimits getMenuLimits(Rect buttonRect, double availableHeight, int index) { | |||
final double maxMenuHeight = availableHeight - 2.0 * _kMenuItemHeight; | |||
double maxMenuHeight = availableHeight - 2.0 * _kMenuItemHeight; |
Piinks
Sep 9, 2021
Contributor
maxMenuHeight
v menuMaxHeight
is a bit confusing.
What if we made this one computedMaxHeight
? Or something like that?
maxMenuHeight
v menuMaxHeight
is a bit confusing.
What if we made this one computedMaxHeight
? Or something like that?
@@ -567,6 +577,7 @@ class _DropdownRoute<T> extends PopupRoute<_DropdownRouteResult<T>> { | |||
scrollOffset = math.min(scrollOffset, preferredMenuHeight - menuHeight); | |||
} | |||
|
|||
assert(menuHeight == menuBottom - menuTop); |
Piinks
Sep 9, 2021
Contributor
Can you add a test that triggers this assertion?
Can you add a test that triggers this assertion?
xu-baolin
Sep 10, 2021
Author
Member
If we only add this assertion to the master branch, there will be many tests that trigger this assertion.
Fortunately, no one has used _MenuLimits.menuBottom
before, so there are no functional issues.
If we only add this assertion to the master branch, there will be many tests that trigger this assertion.
Fortunately, no one has used _MenuLimits.menuBottom
before, so there are no functional issues.
xu-baolin
Sep 10, 2021
Author
Member
This is just to check that the metrics calculated by this function are correct.
I didn't think of a good way to test and trigger it.
This is just to check that the metrics calculated by this function are correct.
I didn't think of a good way to test and trigger it.
b2550fe
into
flutter:master
Fixes #89029
This is an enhanced patch of #76493