Skip to content

Conversation

@davidhicks980
Copy link
Contributor

@davidhicks980 davidhicks980 commented Jun 27, 2024

This PR is aimed at (1) reducing the private API surface of _MenuAnchorState to make migration into RawMenuAnchor simpler, and (2) fixing focus-related bugs.

Directional focus handling was moved from MenuAnchor (_MenuDirectionalFocusAction, _MenuNextFocusAction, and _MenuPreviousFocusAction) into SubmenuButton (_SubmenuDirectionalFocusAction). MenuAnchor now behaves similarly to a flat FocusScope, which makes it easier to customize. A future PR will ideally expose or remove the remaining internals (_lastItemFocusNode, _firstItemFocusNode, _isRoot, etc). All previous framework tests are passing, and additional tests were added for fixes (MenuAnchor tab traversal, reopened menus not being focusable), and to test MenuAnchor focus behavior separately from MenuBar.

However, one example test had to be changed. I'm not sure why the previous example test was working to begin with, as submenu buttons are supposed to open on focus, but this behavior was not observed in the original test.

Fixes #144381, #150334.

One added feature is the ability to move between top-level horizontal submenus if a horizontal movement is made on a vertical menu item that has no children in the movement direction. This behavior was observed on Google Docs, MacOS, and various other menu systems I encountered.

Screen.Recording.2024-07-01.at.1.37.25.AM.mov

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Jun 27, 2024
@github-actions github-actions bot added d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos labels Jul 1, 2024
@davidhicks980 davidhicks980 marked this pull request as ready for review July 2, 2024 10:56
@Piinks Piinks requested review from Piinks and dkwingsmt July 3, 2024 18:15
node: _menuScopeNode,
skipTraversal: !isOpen,
canRequestFocus: isOpen,
descendantsAreFocusable: true,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the default anyhow. It's not explicitly the default, since it's nullable, but it works out that way. Does setting this actually make a difference?

Copy link
Contributor Author

@davidhicks980 davidhicks980 Jul 16, 2024

Choose a reason for hiding this comment

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

Surprisingly, it did make a difference on my master branch. The menus can be traversed multiple times test fails when omitted, but I haven't explored why this is.

[✓] Flutter (Channel master, 3.24.0-1.0.pre.127, on macOS 14.0 23A344 darwin-arm64, locale en-US)
    • Flutter version 3.24.0-1.0.pre.127 on channel master at /Users/davidhicks/fvm/versions/master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision fbb12c2c61 (3 hours ago), 2024-07-15 18:34:38 -0400
    • Engine revision f1363fb7c2
    • Dart version 3.6.0 (build 3.6.0-36.0.dev)
    • DevTools version 2.37.1

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, that is odd. I guess there must be an edge case in there somewhere.

Copy link
Contributor

@gspencergoog gspencergoog left a comment

Choose a reason for hiding this comment

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

32384589-a60f0e74-c078-11e7-9bc1-e5b5287aea9d

Copy link
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

@gspencergoog gspencergoog added the autosubmit Merge PR when tree becomes green via auto submit App label Aug 6, 2024
@auto-submit auto-submit bot merged commit faabe3a into flutter:master Aug 6, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Aug 7, 2024
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Aug 7, 2024
Manual roll requested by [email protected]

flutter/flutter@1dd7141...0a7f8af

2024-08-06 [email protected] Support clearing selection programmatically through SelectableRegionState (flutter/flutter#152882)
2024-08-06 [email protected] Roll Flutter Engine from aabd582e9c7e to 206e86ee8a40 (4 revisions) (flutter/flutter#152962)
2024-08-06 49699333+dependabot[bot]@users.noreply.github.com Bump actions/upload-artifact from 4.3.4 to 4.3.6 (flutter/flutter#152964)
2024-08-06 49699333+dependabot[bot]@users.noreply.github.com Bump github/codeql-action from 3.25.15 to 3.26.0 (flutter/flutter#152965)
2024-08-06 [email protected] [tool] Guard process writes to frontend server in `ResidentCompiler` (flutter/flutter#152358)
2024-08-06 [email protected] Fix Linux_android_emu tests late initialization errors (flutter/flutter#152932)
2024-08-06 [email protected] Marks Mac integration_ui_test_test_macos to be flaky (flutter/flutter#152213)
2024-08-06 [email protected] Roll pub packages (flutter/flutter#152956)
2024-08-06 [email protected] [API Examples] `scroll_direction.0_test.dart` & `growth_direction.0_test.dart` (flutter/flutter#152941)
2024-08-06 [email protected] [devicelab] opt gallery benchmarks and platform view test into merged thread mode. (flutter/flutter#152940)
2024-08-06 [email protected] Roll Flutter Engine from e97955bf12ac to aabd582e9c7e (1 revision) (flutter/flutter#152948)
2024-08-06 [email protected] Roll pub packages (flutter/flutter#152945)
2024-08-06 [email protected] [material/menu_anchor.dart] MenuAnchor focus refactoring for RawMenuAnchor (flutter/flutter#150950)
2024-08-06 [email protected] Roll Flutter Engine from 99da2cab3f6d to e97955bf12ac (2 revisions) (flutter/flutter#152944)
2024-08-06 [email protected] fix: add parameter to maintainState of SearchDelegate (flutter/flutter#152444)
2024-08-06 [email protected] Feat: Add fillColor property for cupertinoCheckbox (flutter/flutter#151761)
2024-08-06 [email protected] Slider does not show changed label value for keyboard users fix (flutter/flutter#152886)
2024-08-06 [email protected] Add Nate Wilson to authors (flutter/flutter#152907)
2024-08-06 [email protected] Roll Flutter Engine from 7fc38bef4775 to 99da2cab3f6d (1 revision) (flutter/flutter#152934)
2024-08-06 [email protected] Roll Packages from 82e8d1e to 551bde5 (12 revisions) (flutter/flutter#152930)
2024-08-06 [email protected] Roll Flutter Engine from 84116159ebfc to 7fc38bef4775 (1 revision) (flutter/flutter#152924)
2024-08-06 [email protected] Roll Flutter Engine from f75ffb65cfe3 to 84116159ebfc (1 revision) (flutter/flutter#152917)
2024-08-06 [email protected] Roll Flutter Engine from f5f6e966e7e7 to f75ffb65cfe3 (2 revisions) (flutter/flutter#152915)

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],[email protected],[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
TytaniumDev pushed a commit to TytaniumDev/flutter that referenced this pull request Aug 7, 2024
…nchor (flutter#150950)

This PR is aimed at (1) reducing the private API surface of _MenuAnchorState to make migration into RawMenuAnchor simpler, and (2) fixing focus-related bugs. 

Directional focus handling was moved from MenuAnchor (_MenuDirectionalFocusAction, _MenuNextFocusAction, and _MenuPreviousFocusAction) into SubmenuButton (_SubmenuDirectionalFocusAction). MenuAnchor now behaves similarly to a flat FocusScope, which makes it easier to customize. A future PR will ideally expose or remove the remaining internals (_lastItemFocusNode, _firstItemFocusNode, _isRoot, etc). All previous framework tests are passing, and additional tests were added for fixes (MenuAnchor tab traversal, reopened menus not being focusable), and to test MenuAnchor focus behavior separately from MenuBar. 

However, [one example test](https://github.com/flutter/flutter/pull/150950/files#diff-a33fa01b59d280784e7c8ed6b704bd005cde95b7d3b649dc82fd58530061a09d) had to be changed. I'm not sure why the previous example test was working to begin with, as submenu buttons are supposed to open on focus, but this behavior was not observed in the original test. 

Fixes flutter#144381, flutter#150334.

One added feature is the ability to move between top-level horizontal submenus if a horizontal movement is made on a vertical menu item that has no children in the movement direction. This behavior was observed on Google Docs, MacOS, and various other menu systems I encountered.

https://github.com/flutter/flutter/assets/59215665/04a42b8a-cc9e-4a50-9d0c-6f2d784cfc78
Buchimi pushed a commit to Buchimi/flutter that referenced this pull request Sep 2, 2024
…nchor (flutter#150950)

This PR is aimed at (1) reducing the private API surface of _MenuAnchorState to make migration into RawMenuAnchor simpler, and (2) fixing focus-related bugs. 

Directional focus handling was moved from MenuAnchor (_MenuDirectionalFocusAction, _MenuNextFocusAction, and _MenuPreviousFocusAction) into SubmenuButton (_SubmenuDirectionalFocusAction). MenuAnchor now behaves similarly to a flat FocusScope, which makes it easier to customize. A future PR will ideally expose or remove the remaining internals (_lastItemFocusNode, _firstItemFocusNode, _isRoot, etc). All previous framework tests are passing, and additional tests were added for fixes (MenuAnchor tab traversal, reopened menus not being focusable), and to test MenuAnchor focus behavior separately from MenuBar. 

However, [one example test](https://github.com/flutter/flutter/pull/150950/files#diff-a33fa01b59d280784e7c8ed6b704bd005cde95b7d3b649dc82fd58530061a09d) had to be changed. I'm not sure why the previous example test was working to begin with, as submenu buttons are supposed to open on focus, but this behavior was not observed in the original test. 

Fixes flutter#144381, flutter#150334.

One added feature is the ability to move between top-level horizontal submenus if a horizontal movement is made on a vertical menu item that has no children in the movement direction. This behavior was observed on Google Docs, MacOS, and various other menu systems I encountered.

https://github.com/flutter/flutter/assets/59215665/04a42b8a-cc9e-4a50-9d0c-6f2d784cfc78
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 11, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App d: api docs Issues with https://api.flutter.dev/ d: examples Sample code and demos f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[material/menu_anchor.dart] Tab focus stopped at SubmenuButton

3 participants