Skip to content

Conversation

maxbeier
Copy link
Contributor

@maxbeier maxbeier commented Apr 19, 2021

Problem

The dropdown menus (NavDropdown) in the header at https://primer.style/components/ currently don't seem to open.

Cause

It's kinda interesting: The details element registers an outside click handler on document to close if it's no longer needed. Unfortunately, React 17 changed the way its event delegation works, and does not listen on document anymore but the node it was mounted on.

So before upgrading the docs to use React 17, binding the click event was done when the event already reached document. But now, when the menu opens, the event bubbles up until it reaches document and triggers the newly added event listener which immediately closes the menu again. It therefore appears to never open.

Solution

This PR reverts the React version back to 16. It's only temporary until primer/doctocat#93 is merged, which replaces the current implementation of the dropdowns in the header navigation.

Screenshots

Screenshot 2021-04-19 at 13 40 59

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge

@changeset-bot
Copy link

changeset-bot bot commented Apr 19, 2021

⚠️ No Changeset found

Latest commit: e01f102

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Apr 19, 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/C2UgiL6FCRuJ1ghyoeoJvBgu9wF4
✅ Preview: https://primer-components-git-fork-maxbeier-main-primer.vercel.app

@vercel vercel bot temporarily deployed to Preview April 19, 2021 11:51 Inactive
@maxbeier maxbeier changed the title fix: NavDropdown open again fix: NavDropdown opens again Apr 19, 2021
@smockle
Copy link
Member

smockle commented Apr 21, 2021

Thanks for the detailed write-up, @maxbeier! I appreciate your effort in tracking this down. Reviewing #942 (comment) makes me concerned about unforeseen consequences of rolling back the React version used on the docs site—I’ll follow-up on the status of primer/doctocat#93 before doing so.

@colebemis
Copy link
Contributor

Fixed by #1340. Thanks again, @maxbeier!

@colebemis colebemis closed this Jul 26, 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.

3 participants