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

Restore "fix: Don’t focus first 'Item' of 'DropdownMenu' and 'SelectMenu' on open" #1293

Merged
merged 6 commits into from
Jun 11, 2021

Conversation

smockle
Copy link
Member

@smockle smockle commented Jun 11, 2021

Reverts #1291, restoring #1270

When these lines (from #1270) removed temporary tabIndex from the container, certain browsers (e.g. Chrome) (but not others, e.g. Safari) set body as the activeElement. Because body is outside FocusTrap (and FocusZone), keyboard navigation between the container’s children was no longer possible.

By deferring the removal of the temporary tabIndex until the container has already lost focus, we avoid focusing body, and so we avoid breaking keyboard navigation. I added code comments in this PR to explain this slightly-more-complicated codepath and the scenario it prevents.

ℹ️ Reviewing this commit may help clarify the difference between this PR’s approach and that in #1270: b343d47

Screen recordings

Safari
safari

Chrome
chrome

Checklist

  • Tested in Safari
  • Tested in Chrome

@changeset-bot
Copy link

changeset-bot bot commented Jun 11, 2021

🦋 Changeset detected

Latest commit: 763bb58

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

This PR includes changesets to release 1 package
Name Type
@primer/components 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

@vercel
Copy link

vercel bot commented Jun 11, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/primer/primer-components/9dYWSspQXzxKB5hAmcx9utTKW7Wg
✅ Preview: https://primer-components-git-revert-1291-revert-1270-don-e5416e-primer.vercel.app

@vercel vercel bot temporarily deployed to Preview June 11, 2021 18:09 Inactive
@smockle smockle marked this pull request as ready for review June 11, 2021 18:16
@vercel vercel bot temporarily deployed to Preview June 11, 2021 18:44 Inactive
@vercel vercel bot temporarily deployed to Preview June 11, 2021 18:47 Inactive
Copy link
Member

@dgreif dgreif left a comment

Choose a reason for hiding this comment

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

Thanks for tracking this down 🏅

@vercel vercel bot temporarily deployed to Preview June 11, 2021 19:18 Inactive
@vercel vercel bot temporarily deployed to Preview June 11, 2021 19:26 Inactive
@smockle smockle enabled auto-merge (squash) June 11, 2021 19:26
@smockle smockle merged commit 1148a71 into main Jun 11, 2021
@smockle smockle deleted the revert-1291-revert-1270-dont-focus-first-item branch June 11, 2021 19:33
@github-actions github-actions bot mentioned this pull request Jun 11, 2021
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.

2 participants