-
-
Notifications
You must be signed in to change notification settings - Fork 29
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
feat: onClickOutside
#46
Conversation
🦋 Changeset detectedLatest commit: 363b0c1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
4bbb7aa
to
d1ffadd
Compare
@sviripa our internals have changed quite a bit since this PR. Sorry for the long time to review! Would you like to refactor it (maybe to a class too), or should I close it? |
@TGlide I'll refactor this one, no worries! |
Hey @sviripa, are you still planning to refactor this, or should one of us push it over the finish line? |
b9300ee
to
4acf14f
Compare
@huntabyte @TGlide I just pushed the changes to make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some small changes needed :)
packages/runed/src/lib/utilities/useClickOutside/useClickOutside.svelte.ts
Outdated
Show resolved
Hide resolved
packages/runed/src/lib/utilities/useClickOutside/useClickOutside.svelte.ts
Outdated
Show resolved
Hide resolved
packages/runed/src/lib/utilities/useClickOutside/useClickOutside.svelte.ts
Outdated
Show resolved
Hide resolved
packages/runed/src/lib/utilities/useClickOutside/useClickOutside.svelte.ts
Outdated
Show resolved
Hide resolved
packages/runed/src/lib/utilities/useClickOutside/useClickOutside.svelte.ts
Outdated
Show resolved
Hide resolved
packages/runed/src/lib/utilities/useClickOutside/useClickOutside.svelte.ts
Outdated
Show resolved
Hide resolved
Just wanted to add that the current method of const rect = event.target.getBoundingClientRect();
const clickedInside = rect.top <= event.clientY && event.clientY <= rect.top + rect.height && rect.left <= event.clientX && event.clientX <= rect.left + rect.width;
if (clickedInside) {
callback();
} On top of that we probably want to add the following guard clause: if (event.target.tagName !== 'DIALOG') {
return;
} As this removes issues with form inside dialogs. This code comes from a gist I often use for click outside functionality: https://gist.github.com/Hugos68/27376946bfd21f431a0ee395f1e5ad71 |
I also think we should use |
@Hugos68 could you please provide an example of how |
Also, you may edit your original comment to |
@TGlide want to revisit this to see if it's g2g based on your previous feedback? |
And perhaps we rename this is |
TODO: investigate what happens when a click occurs inside of an |
Closing in favor of #190 for deployment |
This PR implements
useClickOutside
requested in #37