Skip to content

Stacking event listeners should be possible #9013

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

Closed
jamess-ais opened this issue Jul 21, 2023 · 2 comments
Closed

Stacking event listeners should be possible #9013

jamess-ais opened this issue Jul 21, 2023 · 2 comments

Comments

@jamess-ais
Copy link

Describe the problem

I'm frustrated having to repeat code when it could be simplified

Describe the proposed solution

on:click|keypress={handleAction}

Opposed to

on:click={handleAction}
on:keypress={handleAction}

Alternatives considered

I am not aware of alternatives.

Importance

would make my life easier

@brunnerh
Copy link
Member

Proposed solution conflicts with event modifiers (like preventDefault).

Also, having click and keypress use the same handler just reeks of using the wrong element.

@Conduitry
Copy link
Member

Yeah, we don't want to use the | syntax for the above reason. But also, I don't think we should be encouraging code like this, for the mentioned accessibility reasons. If you really find yourself attaching the same handler to both the click and keypress events on a lot of elements, you can write an Action that wraps this behavior and attaches and removes both event handlers from the node.

@Conduitry Conduitry closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2023
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

No branches or pull requests

3 participants