-
Notifications
You must be signed in to change notification settings - Fork 9
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
discuss clickOutside
action
#4
Comments
A custom event is better imo |
I would say callbacks are always better. Secondly, there can be some problems with Typescript. I'm not sure there is any solution to the typing issue, that this code
now produces this error
Same goes to all custom events. It's simple enough to handle in the VDom world, but I'm not sure how to handle it in Svelte except wrapping these DOM elements with components, which is mad. |
that's a great point. I wonder if there's any way to ignore that type error in svelte-2-tsx. but you're totally right |
I think events seems like a more intuitive developer experience. Any new feelings on this or coming up with a standard? I love the idea of default actions. I see that longpress and clickOutside take the two different approaches at the moment though. |
yeah i'm aware - because contributed by different people haha. there's some policymaking to be done here. eg nobody thinks we should have 3 callbacks for |
Two things I would like to be considered when implementing this:
|
Just +1'ing this. We need a way to exclude elements or some other clever solution. e.g. clicking my mobile menu button ends up keeping the mobile menu open because I've both clicked outside and clicked the menu button. |
considerations
<div use:clickOutside on:click_outside={handleClickOutside}>
. is this better? seems verbose and indirect. perhaps a rule of thumb is if the action only creates one custom event, then just put it inside paramsThe text was updated successfully, but these errors were encountered: