Add RawMenuAnchor close order migration guide#13145
Conversation
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.
Summary of ChangesHello, 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
🧠 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
Activity
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
Updated the title to reflect the change in closing order for RawMenuAnchor.
|
Visit the preview URL for this PR (updated for commit f152ad7): https://flutter-docs-prod--pr13145-raw-menu-anchor-close-order-ai6awsfg.web.app |
sfshaza2
left a comment
There was a problem hiding this comment.
lgtm, but I'd like to wait for @dkwingsmt to review before landing.
|
Oh wait -- don't we need to add a timeline? Sorry, have been out for a few days. |
…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>
…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>
|
We might want to add a timeline to this page, now that flutter/flutter#182357 has been officially merged. |
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
of 80 characters or fewer.