Skip to content

Conversation

@pksjce
Copy link
Contributor

@pksjce pksjce commented Jan 22, 2024

Closes https://github.com/github/accessibility-audits/issues/4641

Bug description
The bug specifically occurs in one case where the action menu does not have a visible anchor and is programmatically opened through a keyboard shortcut combination. Specifically in the code viewer, on hitting the SHIFT + CTRL + C combination, you can see the actionmenu emerge at the cursor position. This action menu can also be accessed at the line level through an anchor thats only visible on focus.
The actual bug is that the focus does not shift from the cursor position into the action menu's first item as expected.
This bug has been especially challenging because it is hard to reproduce in it's entireity. One can fiddle around with tab button and fix the focus params such that the bug becomes nonexistent. Also I was not successful in creating a minimum reproduction of the issue in a storybook. #4025 . Any advise on fixing this is welcome.

Root cause analysis
The current theory is that as per the spec on focus-visible https://drafts.csswg.org/selectors/#indicate-focus , these lines tell us what could the problem be.

"If the previously-focused element indicated focus, and a script causes focus to move elsewhere, indicate focus on the newly focused element.
Conversely, if the previously-focused element did not indicate focus, and a script causes focus to move elsewhere, don’t indicate focus on the newly focused element."

So if the focus shifts programmatically then the spec does not require to apply the focus-visible pseudo class.

Proposed fix
After much deliberation, I think our best chance is to fix the issue to our best of knowledge and see if it fixes the actual issue.
We will make sure that the first item in action menu always receives focus when it opens by more robust css. This should be the right solution.

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Merge checklist

@pksjce pksjce requested review from a team and broccolinisoup January 22, 2024 12:15
@changeset-bot
Copy link

changeset-bot bot commented Jan 22, 2024

🦋 Changeset detected

Latest commit: ecb8af8

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

This PR includes changesets to release 1 package
Name Type
@primer/react Patch

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

@pksjce pksjce requested review from TylerJDev and joshblack January 22, 2024 12:15
@github-actions
Copy link
Contributor

github-actions bot commented Jan 22, 2024

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 113.01 KB (+0.01% 🔺)
packages/react/dist/browser.umd.js 113.67 KB (+0.01% 🔺)

@pksjce pksjce force-pushed the pk/fix-action-menu-foxus branch from fba7e40 to a2beb45 Compare January 25, 2024 09:59
@github-actions github-actions bot temporarily deployed to storybook-preview-4166 January 25, 2024 10:03 Inactive
@github-actions github-actions bot temporarily deployed to storybook-preview-4166 January 25, 2024 10:08 Inactive
@joshblack
Copy link
Member

@pksjce was trying to re-create this issue again on dotcom and am having trouble getting the shortcut to trigger the menu 🤔 I just get the screen jumping all the way to the bottom. Was curious if others are observing the same or if it was just me.

@TylerJDev
Copy link
Member

@joshblack, yup I'm getting the same behavior. I've asked this in one of the slack channels to see if this functionality was removed or not.

@pksjce
Copy link
Contributor Author

pksjce commented Feb 1, 2024

Hi @TylerJDev @joshblack , I see that they seemed to have fixed this. Though I'm still having some challenges getting it working. I'm trying to get a review lab out so we can test the fix

@TylerJDev
Copy link
Member

@pksjce, @joshblack, I'm now able to open the menu in code view. Let me know if you need an additional look within the review lab too!

@TylerJDev
Copy link
Member

I also noticed a bug that this PR seems to fix. Opening up an ActionMenu within Safari via mouse and navigating with arrow keys won't produce any focus indication.

Screen.Recording.2024-02-02.at.9.35.02.AM.mov

Video description: I'm in a Storybook story for ActionMenu on Safari, and I open the menu with my mouse. Afterwards I navigate through the menu using both up/down arrow keys. As I navigate through the menu, the focus indicator is not present. It only appears when I press any other key outside of up/down arrow keys.

@pksjce, @joshblack, could y'all try reproducing this to see if it's the same behavior for all of us? Here are the reproduction steps:

  1. Open up any Storybook story for ActionMenu in Safari
  2. Open the menu with your mouse
  3. As soon as the menu is open, try navigating the menu with either Up Arrow or Down Arrow
  4. Observe if focus indicator is present or not

@joshblack
Copy link
Member

@TylerJDev is this an implementation behavior of Safari where it does not show focus if the menu is opened with a click and then keyboard is used? The list items clearly have focus, and :focus-visible styling works in Safari, but it does not seem to be triggered in this case 🤔

The fix above totally works because the focus-visible polyfill adds the appropriate classes/attributes so the styling kicks in but was wondering if this was a behavior that Safari has implemented or is something else at play.

dependabot bot and others added 4 commits February 8, 2024 12:03
Bumps [@babel/cli](https://github.com/babel/babel/tree/HEAD/packages/babel-cli) from 7.22.10 to 7.23.9.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.9/packages/babel-cli)

---
updated-dependencies:
- dependency-name: "@babel/cli"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [terser](https://github.com/terser/terser) from 5.17.6 to 5.27.0.
- [Changelog](https://github.com/terser/terser/blob/master/CHANGELOG.md)
- [Commits](terser/terser@v5.17.6...v5.27.0)

---
updated-dependencies:
- dependency-name: terser
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…4186)

Bumps [@storybook/source-loader](https://github.com/storybookjs/storybook/tree/HEAD/code/lib/source-loader) from 7.6.7 to 7.6.10.
- [Release notes](https://github.com/storybookjs/storybook/releases)
- [Changelog](https://github.com/storybookjs/storybook/blob/next/CHANGELOG.md)
- [Commits](https://github.com/storybookjs/storybook/commits/v7.6.10/code/lib/source-loader)

---
updated-dependencies:
- dependency-name: "@storybook/source-loader"
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
* Improve aria-labels for example icon buttons and add guidance

* test(vrt): update snapshots

---------

Co-authored-by: joshblack <[email protected]>
dependabot bot and others added 5 commits February 8, 2024 12:03
* chore(deps): bump @github/combobox-nav from 2.1.7 to 2.3.1

Bumps [@github/combobox-nav](https://github.com/github/combobox-nav) from 2.1.7 to 2.3.1.
- [Release notes](https://github.com/github/combobox-nav/releases)
- [Commits](github/combobox-nav@v2.1.7...v2.3.1)

---
updated-dependencies:
- dependency-name: "@github/combobox-nav"
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* test: add fallback for Element#scrollIntoView

* chore: fix eslint warning

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Josh Black <[email protected]>
* oof

* Create thirty-mirrors-switch.md

* test(vrt): update snapshots

* fix missing var

* fix parens

* test(vrt): update snapshots

---------

Co-authored-by: langermank <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Copy link
Member

@joshblack joshblack left a comment

Choose a reason for hiding this comment

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

LGTM to fix this in the interim while we figure out what on earth is going on 😅

@pksjce pksjce added this pull request to the merge queue Feb 9, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 9, 2024
@pksjce pksjce removed the request for review from broccolinisoup February 12, 2024 00:13
@pksjce pksjce added this pull request to the merge queue Feb 12, 2024
Merged via the queue into main with commit c66b808 Feb 12, 2024
@pksjce pksjce deleted the pk/fix-action-menu-foxus branch February 12, 2024 00:23
@primer primer bot mentioned this pull request Feb 11, 2024
@TylerJDev TylerJDev mentioned this pull request Mar 1, 2024
13 tasks
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.

6 participants