New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add vertical alignment offset to the MenuAnchor
widget when overflowing
#123740
Add vertical alignment offset to the MenuAnchor
widget when overflowing
#123740
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
MenuAnchor
widgetMenuAnchor
widget when overflowing
@gspencergoog @justinmc @TahaTesser This is ready for review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 . Thanks again for the menu bug fix!
But @gspencergoog should also take a look before merge.
@@ -3156,7 +3156,12 @@ class _MenuLayout extends SingleChildLayoutDelegate { | |||
} else if (offBottom(y)) { | |||
final double newY = anchorRect.top - childSize.height; | |||
if (!offTop(newY)) { | |||
y = newY; | |||
// Only move the menu up if it is the root menu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Period at the end of the sentence here and in the comments in the test below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
await tester.tap(find.text('Tap me')); | ||
await tester.pumpAndSettle(); | ||
|
||
await tester.pumpWidget( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I would typically split this into 2 separate tests. The main reason is better feedback when there is a failure in one of them. But it's up to you if you think that's useful here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When does it make sense to have one test have multiple tester.pumpWidget
widgets? In a previous PR, @TahaTesser told me to place both the default and explicit test cases in a single test since the separate test would only test the default behaviour.
Refactored nonetheless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@TahaTesser told me to place both the default and explicit test cases in a single test since the separate test would only test the default behaviour.
That was the clip behavior test, which is a much simpler test. Just checking the clip property.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -3177,7 +3177,12 @@ class _MenuLayout extends SingleChildLayoutDelegate { | |||
} else if (offBottom(y)) { | |||
final double newY = anchorRect.top - childSize.height; | |||
if (!offTop(newY)) { | |||
y = newY; | |||
// Only move the menu up if it is the root menu. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment doesn't appear to be related to the conditional, since there can be menus that are horizontal that aren't root menus. Sure, it's weird, but it's possible (you could have a menu bar that appears when you open another menu item).
Probably you just want to adjust the comment to talk about horizontal menus, but if you did want to actually only do it if it's the root menu, you would have to pass that information in to this layout widget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, updated the comment. I tested the behaviour of having a MenuBar as a child of a SubmenuButton in a MenuAnchor widget and it's behaving as it should.
Google testing infrastructure is currently broken. We'll have to wait for a fix for now. |
…t when overflowing (flutter/flutter#123740)
…rflowing (flutter#123740) Positioning of cascading menus.
…t when overflowing (flutter/flutter#123740)
…t when overflowing (flutter/flutter#123740)
Adds a vertical offset to the
MenuAnchor
widget when the menu cannot be fitted below the anchor and there is enough space above it. Previously, the vertical offset would be ignored in such conditions.Still needs a test.simplescreenrecorder-2023-03-30_01.45.29.mp4
Repro code:
Fixes #122096