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

Handle on outside clicks in reverse order for overlay #1251

Merged
merged 9 commits into from
Jun 16, 2021

Conversation

VanAnderson
Copy link
Contributor

overlay on click-3

Transplant logic from onEscapePress to onOutsideClick - this allows us to have Overlays inside of overlays that will respect proper close behavior!

@changeset-bot
Copy link

changeset-bot bot commented May 25, 2021

🦋 Changeset detected

Latest commit: 49a1190

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 May 25, 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/AJTRgWD4eKmb26knEd7t5zFtR5UU
✅ Preview: https://primer-components-git-vananderson-handle-on-outsi-e693ec-primer.vercel.app

if (handlers.length === 0) {
document.addEventListener('click', handleClick)
}
setTimeout(() => handlers.push(onOutsideClickInternal))
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 is the only way I can get things to work - otherwise the outside click event for the DropdownModal fires at the same time that the dropdown opens.

@vercel vercel bot temporarily deployed to Preview May 25, 2021 20:15 Inactive
@vercel vercel bot temporarily deployed to Preview May 27, 2021 20:46 Inactive
@vercel vercel bot temporarily deployed to Preview May 27, 2021 23:19 Inactive
@vercel vercel bot temporarily deployed to Preview May 28, 2021 02:26 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.

This new implementation requires users to memoize their useOnOutsideClick inputs properly, but I think it's the best we can do for today. Looks good to me, but it would be good to get another set of eyes on it since I helped with implementation

@vercel vercel bot temporarily deployed to Preview June 16, 2021 15:47 Inactive
@vercel vercel bot temporarily deployed to Preview June 16, 2021 18:15 Inactive
@smockle
Copy link
Member

smockle commented Jun 16, 2021

@dgreif @VanAnderson Would y’all mind taking a look at the edits in 2b2f5e8? I synchronously reviewed them with @dgreif already, but I’m a bit wary to approve and merge this since I contributed to that refactor.

@dgreif
Copy link
Member

dgreif commented Jun 16, 2021

@smockle you changes look great. I'm comfortable merging this PR at this point. We can always circle back with refactors if needed, but the current code both solves the problem and doesn't have side-effects like the first couple iterations that were dependent on memoized props.

@vercel vercel bot temporarily deployed to Preview June 16, 2021 23:03 Inactive
@dgreif dgreif enabled auto-merge (squash) June 16, 2021 23:04
@dgreif dgreif merged commit 528e9a4 into main Jun 16, 2021
@dgreif dgreif deleted the VanAnderson/handle-on-outside-click branch June 16, 2021 23:07
@github-actions github-actions bot mentioned this pull request Jun 16, 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.

None yet

3 participants