Skip to content
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

Add overflow menu (ActionMenu) to focus zone in ActionBar #2259

Merged
merged 9 commits into from
Oct 6, 2023

Conversation

TylerJDev
Copy link
Contributor

@TylerJDev TylerJDev commented Sep 27, 2023

Authors: Please fill out this form carefully and completely.

Reviewers: By approving this Pull Request you are approving the code change, as well as its deployment and mitigation plans.
Please read this description carefully. If you feel there is anything unclear or missing, please ask for updates.

What are you trying to accomplish?

PR adds the overflow menu (ActionMenu) to the focus trap within ActionBar. This is based off of the following issue: https://github.com/github/primer/issues/1131.

Screenshots

Before PR, shows overflow menu being reachable only through tab
Screen.Recording.2023-09-28.at.2.13.38.PM.mov

Video shows arrow key navigation through the ActionBar component. The navigation is trapped within the menu items and does not reach the overflow menu. Video then shows usage of the Tab key, focusing directly onto the overflow menu.

Current PR, shows overflow menu being placed within focus trap
Screen.Recording.2023-09-28.at.1.48.29.PM.mov

Video shows arrow key navigation through the ActionBar component. The navigation is trapped within the component, and reaches the overflow menu without having to press Tab to focus onto it.

Integration

List the issues that this change affects.

https://github.com/github/primer/issues/1131

Risk Assessment

  • Low risk the change is small, highly observable, and easily rolled back.
  • Medium risk changes that are isolated, reduced in scope or could impact few users. The change will not impact library availability.
  • High risk changes are those that could impact customers and SLOs, low or no test coverage, low observability, or slow to rollback.

What approach did you choose and why?

PR adds ActionMenu to focus trap within ActionBar. Currently, the menu must be tabbed into separately rather than a part of the focus trap.

This also adds the ability in focus_group to have tabindex set back onto the invoker button of the popover menu. This fixes a bug in ActionBar, where if clicked outside of that menu whilst active, focus would be stuck on a menuitem and not the invoker.

Anything you want to highlight for special attention from reviewers?

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Lookbook)
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

Take a look at the What we look for in reviews section of the contributing guidelines for more information on how we review PRs.

@changeset-bot
Copy link

changeset-bot bot commented Sep 27, 2023

🦋 Changeset detected

Latest commit: cec8edb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/view-components Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@TylerJDev TylerJDev temporarily deployed to preview September 27, 2023 16:46 — with GitHub Actions Inactive
@github-actions github-actions bot added the javascript Pull requests that update Javascript code label Sep 27, 2023
@TylerJDev TylerJDev temporarily deployed to preview September 28, 2023 15:10 — with GitHub Actions Inactive
@TylerJDev TylerJDev temporarily deployed to preview September 28, 2023 17:20 — with GitHub Actions Inactive
@@ -111,7 +137,7 @@ export default class FocusGroupElement extends HTMLElement {
let el: HTMLElement | null = focusEl
do {
el = el.closest(`[popover]:not(:popover-open)`)
if (el?.popover === 'auto') {
if (el?.popover === 'auto' && !['ArrowRight', 'ArrowLeft'].includes(event.key)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This prevents the left and right arrow keys from triggering a menu. Without, if you were to navigate the ActionBar with arrow keys, the menu would automatically open when either key is pressed.

@TylerJDev TylerJDev marked this pull request as ready for review September 28, 2023 21:15
@TylerJDev TylerJDev requested review from a team and camertron September 28, 2023 21:15
Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

Cool, thank you!

Copy link
Contributor

@camertron camertron left a comment

Choose a reason for hiding this comment

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

Ah sorry. I approved but forgot I wanted to ask for some tests first 😄

Copy link
Member

@jonrohan jonrohan left a comment

Choose a reason for hiding this comment

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

Looks great thanks for the help!

@jonrohan jonrohan merged commit a2fe613 into main Oct 6, 2023
28 checks passed
@jonrohan jonrohan deleted the tylerjdev/action-bar-focus-trap branch October 6, 2023 21:05
@jonrohan jonrohan temporarily deployed to preview October 6, 2023 21:05 — with GitHub Actions Inactive
@primer primer bot mentioned this pull request Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants