[material/menu_anchor.dart] Ensure positioned menus always begin animating at the target position#182932
Conversation
There was a problem hiding this comment.
Code Review
This pull request adjusts the positioning logic for animated menus in _MenuLayout. In getPositionForChild, it now checks if menuPosition is provided. If so, it returns the calculated finalPosition immediately, which prevents the menu from animating its position from the anchor's edge. This ensures menus opened at a specific coordinate start their animation at that target position. A new widget test is added to confirm this behavior.
|
In your "after" video, I noticed that the menu repositions when you click outside. Is it intentional or a bug? It feels like a bug to me. (According to your video, it seems that this only happens if you click after the animation has settled.) |
|
@dkwingsmt That's because I recorded a dumb video where I mixed right and left clicks. I'll update the video. |
I thought about it. But honestly I think this isn't the right behavior for either right clicks and left clicks. |
|
@dkwingsmt This is currently how MacOS menus work and Angular Material menus work: https://rc.material.angular.dev/components/menu/overview#context-menu. However, we can always change the behavior with another PR. The main purpose of this PR is to fix the position where the menu opens. |
dkwingsmt
left a comment
There was a problem hiding this comment.
LGTM. Thank you for the fix!
…begin animating at the target position (flutter/flutter#182932)
flutter/flutter@195ae7b...3f400d7 2026-03-11 [email protected] Roll Clang to 80743bd43fd5b38fedc503308e7a652e23d3ec93 (flutter/flutter#182919) 2026-03-11 [email protected] Roll Fuchsia Linux SDK from 8C_qfgWgoNhkV0_Mn... to QD887D4OanteB7UKM... (flutter/flutter#183492) 2026-03-11 [email protected] Roll Dart SDK from fecf806be5d0 to 8531f7c2bdae (2 revisions) (flutter/flutter#183489) 2026-03-11 [email protected] [impeller] Use the GLES3 shaders in the embedder if supported (flutter/flutter#180072) 2026-03-11 [email protected] Roll Dart SDK from ae2be9700800 to fecf806be5d0 (1 revision) (flutter/flutter#183482) 2026-03-11 [email protected] Add GLES support for the same pixel formats for copying texture -> buffer as when copying buffer -> texture (flutter/flutter#183428) 2026-03-11 [email protected] Roll Skia from 257d04225d0c to 0cab3e4ee34b (8 revisions) (flutter/flutter#183476) 2026-03-10 [email protected] Fix GitHub workflows to use the `flutteractionsbot` mirror for PR branches. (flutter/flutter#183470) 2026-03-10 [email protected] [material/menu_anchor.dart] Ensure positioned menus always begin animating at the target position (flutter/flutter#182932) 2026-03-10 [email protected] Roll pub packages (flutter/flutter#183467) 2026-03-10 [email protected] Roll Dart SDK from ebef6c849489 to ae2be9700800 (4 revisions) (flutter/flutter#183460) 2026-03-10 [email protected] Roll Skia from 4b35832cc7ea to 257d04225d0c (5 revisions) (flutter/flutter#183457) 2026-03-10 [email protected] dev: Use a super-parameter in several missed cases (flutter/flutter#182251) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
This PR makes animated positioned menus (usually context menus that treat the whole screen as a menu anchor) begin opening at the user's pointer rather than the top or bottom of the menu anchor.
Fixes #182929
Before:
Screen.Recording.2026-02-26.at.12.46.32.AM.mov
After (the menu closes on left-click, but repositions on right-click, unless it is external to the red menu anchor surface)
Screen.Recording.2026-02-26.at.2.03.44.AM.mov
If possible, we should make sure this lands in stable when the menu animations land in stable.
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.