Skip to content

Add RawMenuAnchor close order migration guide#13145

Merged
sfshaza2 merged 5 commits intomainfrom
raw-menu-anchor-close-order
Mar 9, 2026
Merged

Add RawMenuAnchor close order migration guide#13145
sfshaza2 merged 5 commits intomainfrom
raw-menu-anchor-close-order

Conversation

@davidhicks980
Copy link
Copy Markdown
Contributor

@davidhicks980 davidhicks980 commented Mar 5, 2026

Description of what this PR is changing or adding, and why:

This PR adds a migration guide for flutter/flutter#182357

Issues fixed by this PR (if any):

182355

PRs or commits this PR depends on (if any):

flutter/flutter#182357

@dkwingsmt

Presubmit checklist

  • If you are unwilling, or unable, to sign the CLA, even for a tiny, one-word PR, please file an issue instead of a PR.
  • If this PR is not meant to land until a future stable release, mark it as draft with an explanation.
  • This PR follows the Google Developer Documentation Style Guidelines—for example, it doesn't use i.e. or e.g., and it avoids I and we (first-person pronouns).
  • This PR uses semantic line breaks
    of 80 characters or fewer.

Closing a RawMenuAnchor now triggers onClose and onCloseRequested callbacks for all descendant RawMenuAnchors in a coordinated sequence, improving the closure behavior and ensuring proper callback execution order.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive migration guide for a significant change in how RawMenuAnchor widgets handle their closing sequence. The guide details the new coordinated callback execution order for onCloseRequested and onClose across parent and descendant menus, providing developers with the necessary information and code examples to update their applications and ensure correct menu behavior.

Highlights

  • RawMenuAnchor Closing Behavior: RawMenuAnchor now coordinates onClose and onCloseRequested callbacks across all descendants, with onCloseRequested triggering top-down and onClose bottom-up.
  • controller.closeChildren() Automation: Manual calls to controller.closeChildren() within onCloseRequested are no longer necessary as the system now handles this automatically.
  • Migration Guide Availability: A new migration guide has been added to explain these changes and provide code examples for adapting existing implementations.
  • dart fix Support: This specific migration is not supported by dart fix, requiring manual code adjustments.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/content/release/breaking-changes/raw-menu-anchor-close.md-order
    • Added a new migration guide document explaining the updated RawMenuAnchor closing behavior.
Activity
  • Author created the pull request to add a migration guide for RawMenuAnchor closing order.
  • Author linked to the related issue #182355 and the dependent PR #182357.
  • Author completed the presubmit checklist, indicating readiness for review.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@davidhicks980 davidhicks980 self-assigned this Mar 5, 2026
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a helpful migration guide for the breaking change in RawMenuAnchor. The guide is well-structured and clearly explains the changes in behavior and the necessary migration steps. I have one minor suggestion to improve the clarity of a sentence in the 'Background' section. Otherwise, the documentation looks great.

Comment thread src/content/release/breaking-changes/raw-menu-anchor-close.md-order Outdated
Updated the title to reflect the change in closing order for RawMenuAnchor.
@flutter-website-bot
Copy link
Copy Markdown
Collaborator

flutter-website-bot commented Mar 5, 2026

Visit the preview URL for this PR (updated for commit f152ad7):

https://flutter-docs-prod--pr13145-raw-menu-anchor-close-order-ai6awsfg.web.app

Comment thread src/content/release/breaking-changes/index.md
Copy link
Copy Markdown
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but I'd like to wait for @dkwingsmt to review before landing.

Copy link
Copy Markdown
Contributor

@dkwingsmt dkwingsmt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

Copy link
Copy Markdown
Contributor

@sfshaza2 sfshaza2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, thx!!

@sfshaza2 sfshaza2 merged commit 7689364 into main Mar 9, 2026
10 checks passed
@sfshaza2 sfshaza2 deleted the raw-menu-anchor-close-order branch March 9, 2026 17:00
@davidhicks980
Copy link
Copy Markdown
Contributor Author

Oh wait -- don't we need to add a timeline? Sorry, have been out for a few days.

github-merge-queue Bot pushed a commit to flutter/flutter that referenced this pull request Apr 7, 2026
…ed on descendants before parent. (#182357)

This PR corrects the order in which onClose() and onCloseRequested() is
called by a RawMenuAnchor tree.

Per @dkwingsmt:

> A close is immediate and should close children immediately before
closing itself, while a closeRequest [can be] async and should
closeRequest children.

Before, calling close() on a parent would call handleCloseRequest() on
its children, leading to children (potentially) finishing their closure
after their parents.

Additionally, if a RawMenuAnchor is already closed, it will not trigger
onCloseRequested.

**Details:**
 
The handleCloseRequest portion of the
_RawMenuAnchorBaseMixin.closeChildren function has been moved into a
requestChildrenClose function to be more explicit.

Additionally, this PR makes handleCloseRequest call
requestChildrenClose() after calling widget.onCloseRequested on
_RawMenuAnchorState. This makes submenus begin closing after their
parent menu begins closing. I also modified the menu_anchor.dart and
raw_menu_anchor.3.dart code to remove a closeChildren call (now
redundant).

Last, this PR makes handleCloseRequest short-circuit if a menu isn't
open. This prevents unncessary widget.onCloseRequest calls when a
submenu is opened, since all sibling menus call handleCloseRequest
before the submenu begins opening.

This is a breaking change. I had to modify one of the DismissMenuAnchor
tests since onCloseRequested is now called on all descendants when a
dismissal occurs. I think it's best to introduce this change because it
can lead to hard-to-track behavior when creating menus (that's how I
discovered it).

Migration guide: flutter/website#13145

Additional tests were added to check the opening and closing behavior. 

Fixes #182355

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot 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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
mbcorona pushed a commit to mbcorona/flutter that referenced this pull request Apr 15, 2026
…ed on descendants before parent. (flutter#182357)

This PR corrects the order in which onClose() and onCloseRequested() is
called by a RawMenuAnchor tree.

Per @dkwingsmt:

> A close is immediate and should close children immediately before
closing itself, while a closeRequest [can be] async and should
closeRequest children.

Before, calling close() on a parent would call handleCloseRequest() on
its children, leading to children (potentially) finishing their closure
after their parents.

Additionally, if a RawMenuAnchor is already closed, it will not trigger
onCloseRequested.

**Details:**
 
The handleCloseRequest portion of the
_RawMenuAnchorBaseMixin.closeChildren function has been moved into a
requestChildrenClose function to be more explicit.

Additionally, this PR makes handleCloseRequest call
requestChildrenClose() after calling widget.onCloseRequested on
_RawMenuAnchorState. This makes submenus begin closing after their
parent menu begins closing. I also modified the menu_anchor.dart and
raw_menu_anchor.3.dart code to remove a closeChildren call (now
redundant).

Last, this PR makes handleCloseRequest short-circuit if a menu isn't
open. This prevents unncessary widget.onCloseRequest calls when a
submenu is opened, since all sibling menus call handleCloseRequest
before the submenu begins opening.

This is a breaking change. I had to modify one of the DismissMenuAnchor
tests since onCloseRequested is now called on all descendants when a
dismissal occurs. I think it's best to introduce this change because it
can lead to hard-to-track behavior when creating menus (that's how I
discovered it).

Migration guide: flutter/website#13145

Additional tests were added to check the opening and closing behavior. 

Fixes flutter#182355

## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant documentation (doc comments with `///`).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.

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](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot 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.

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md

---------

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
@dkwingsmt
Copy link
Copy Markdown
Contributor

We might want to add a timeline to this page, now that flutter/flutter#182357 has been officially merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants