-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add use-detect-outside-click
hook
#8
base: master
Are you sure you want to change the base?
Conversation
3bd8862
to
38ee5d5
Compare
38ee5d5
to
a944870
Compare
target instanceof Element && | ||
!ref?.current?.contains(target) | ||
) { | ||
setActive(false); |
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.
Wouldn't this be more beneficial if this was a callback?
Usually a click outside is an action, when we click outside an element, we want to trigger a callback.
For example, a simple modal or a dropdown menu, clicking outside those elements would trigger a close.
setActive(false); | |
callback(); |
I'm not seeing a good case for using a state @luisdralves, but maybe you have a more explicit example.
WDYT @rafaelcruzazevedo?
This PRs adds the
use-detect-outside-click
hook. It detects if a click is inside or outside a component