-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Feature request: event handlers with only modifiers, e.g. on:click|stopPropagation #3049
Comments
I think this would be confusing. An event directive with no handler and no modifiers means an event that's forwarded to the parent component. This would make adding modifiers to it do something completely different. |
Ah yeah, forgot about that feature. Doesn't seem worth it in that case. |
I have wanted this myself in the past. What if we had something like this? <div on:click|stopPropagation={}>
...
</div> It's not not confusing, but it is arguably nicer than |
I was also thinking about something like that. Do we want the |
Yeah, it's definitely a straw man. I'll reopen this anyway, in case we think of something better |
Going to vote against this mostly, since If it did get turned into a feature, I'd suggest |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I think this is something most people intuitively expect Svelte to already do, so I don't think this issue should be closed. |
+1 for |
Are you sure this doesn't already work, at least as of today? I'm using bare |
Apprently, it does work now: https://svelte.dev/repl/d3f83ef507d74e558f5a25bd8fd24e0c?version=3.46.4 |
|
Since |
stopPropagation can be useful on its own, as a way of catching "cancel when user clicks away" functionality and preventing it from being triggered by clicks that originate within the focused thing itself.
It would be nice to be able to use the event modifier without having to supply a "noop" handler, e.g.
The text was updated successfully, but these errors were encountered: