Skip to content

Improve and fix MenuAnchor/MenuItemButton UX for desktop #139395

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

Closed
1 task
Fernthedev opened this issue Dec 1, 2023 · 9 comments · Fixed by #139396
Closed
1 task

Improve and fix MenuAnchor/MenuItemButton UX for desktop #139395

Fernthedev opened this issue Dec 1, 2023 · 9 comments · Fixed by #139396
Labels
a: desktop Running on desktop c: new feature Nothing broken; request for a new capability f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team triaged-design Triaged by Design Languages team

Comments

@Fernthedev
Copy link
Contributor

Fernthedev commented Dec 1, 2023

MenuAnchor for Material 3 is great for contextual menus but there are some minor issues related to accessibility. Specifically, keyboard navigation does not auto-select an element when opening the menu. This causes some UX confusion where the user has to navigate further to access the menu he or she just opened, which in my case is not user friendly.

Setup:

  • Material 3
  • Windows 10 22H2
  • Flutter 3.16.2

Relevant PR:

Thanks Flutter Team!

@Fernthedev
Copy link
Contributor Author

I started looking and saw TapRegion was the ancestor widget which handles outside clicks for closing the menu.
This line is responsible for the secondary tap issue mentioned previously.

if (event is! PointerDownEvent || event.buttons != kPrimaryButton) {
return;
}

@huycozy
Copy link
Member

huycozy commented Dec 4, 2023

Hi @Fernthedev
Using the 1st example at MenuAnchor, I can navigate between menus normally with arrow keys. I'm not sure which case autofocus can be used, could you be more specific?

Screen.Recording.2023-12-04.at.16.17.14.mov

Also, will the linked PR solve the 2nd and 3rd problems above? Or are they other issues?

@huycozy huycozy added the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 4, 2023
@Fernthedev
Copy link
Contributor Author

Hi, thanks for getting back to me. The other issues will not be resolved with the PR. I might look into those if Flutter gives me a direction for resolving them. Specifically, whether if TapRegion should have an option to listen to other mouse buttons, or some other solution.

As for the 1st issue, yes you can navigate the menu with the keyboard. However the autofocus attribute is useful in the case where the focus can be requested for a specific element on menu open. For my use case, this is better as it doesn't rely on Flutter's keyboard navigation to figure out how to focus the menu in a listview (Maybe that's just me or a bug in my code, but I don't think the PR can be disregarded yet anyways). I'll try to get some video footage later today.

Thanks!

@github-actions github-actions bot removed the waiting for customer response The Flutter team cannot make further progress on this issue until the original reporter responds label Dec 4, 2023
@huycozy
Copy link
Member

huycozy commented Dec 5, 2023

However the autofocus attribute is useful in the case where the focus can be requested for a specific element on menu open.

Thanks for the update. Labeling this point as a feature request.

For two remaining issues, please file separate issues for them for better tracking.

@huycozy huycozy added c: new feature Nothing broken; request for a new capability framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. a: desktop Running on desktop team-design Owned by Design Languages team f: focus Focus traversal, gaining or losing focus and removed in triage Presently being triaged by the triage team labels Dec 5, 2023
@Fernthedev
Copy link
Contributor Author

Done, should I adjust this issue to focus on the autofocus feature then?

Here are the new subsequent issues:
#139555
#139556

@HansMuller
Copy link
Contributor

CC @gspencergoog

@HansMuller HansMuller added P2 Important issues not at the top of the work list triaged-design Triaged by Design Languages team labels Dec 6, 2023
@gspencergoog
Copy link
Contributor

Yes, let's focus (haha!) on the autofocus issue for this one.

@Fernthedev
Copy link
Contributor Author

Here's some footage example showcasing the difficulty of navigating to the menu in my desktop app. It also accidentally shows a separate MenuAnchor keyboard bug, which seems harder to resolve since each MenuAnchor is individually controlled.

https://streamable.com/t807zn

auto-submit bot pushed a commit that referenced this issue Jun 27, 2024
MenuAnchor for Material 3 is great for contextual menus but there are some minor issues related to accessibility.
This PR aims to close the gap by adding `autofocus` to the menu item button so keyboard navigation is more intuitive. Otherwise, it becomes a mess to navigate through just keyboards.

Partially resolves #139395

## Additional Notes

I should mention, I have not written tests for this due to it's trivial nature. I also lack the experience of writing Flutter tests in general, so if someone feels inclined to take over this PR and add it they're welcome to.
@huycozy huycozy added the r: fixed Issue is closed as already fixed in a newer version label Jun 27, 2024
victorsanni pushed a commit to victorsanni/flutter that referenced this issue Jul 8, 2024
MenuAnchor for Material 3 is great for contextual menus but there are some minor issues related to accessibility.
This PR aims to close the gap by adding `autofocus` to the menu item button so keyboard navigation is more intuitive. Otherwise, it becomes a mess to navigate through just keyboards.

Partially resolves flutter#139395

## Additional Notes

I should mention, I have not written tests for this due to it's trivial nature. I also lack the experience of writing Flutter tests in general, so if someone feels inclined to take over this PR and add it they're welcome to.
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: desktop Running on desktop c: new feature Nothing broken; request for a new capability f: focus Focus traversal, gaining or losing focus f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list r: fixed Issue is closed as already fixed in a newer version team-design Owned by Design Languages team triaged-design Triaged by Design Languages team
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants