fix: NavDropdown
opens again
#1173
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ondocument
to close if it's no longer needed. Unfortunately, React 17 changed the way its event delegation works, and does not listen ondocument
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 reachesdocument
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
Merge checklist