Support for some other Action Options and Key Modifiers would be great
See original GitHub issueThis issue is inspired by #440, #442, and Vue’s v-on
directive. Out of the listed “Modifiers”, Stimulus already has the following:
:capture
:once
:passive
:!passive
The .{keyAlias}
Key Modifier is already being handled in #442 for keyboard events. We can have the equivalent .left
, .right
, and .middle
Key Modifiers for mouse events as well.
On top of that, seems like having a :self
Action Option would be great. Maybe an equivalent :!self
as well?
And I know that the :stop
and :prevent
Action Options aren’t necessary since the same can be done inside the handler itself, but it’d be nice to have those options as well to reduce event.stopPropagation()
and event.preventDefault()
inside most handlers.
Thoughts?
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Change the behavior of the modifier keys on Mac
You can change the action that modifier keys, such as Control or Option, perform when you press them. On your Mac, choose Apple...
Read more >Modifiers - Grammar - Academic Guides at Walden University
A modifier is a word, phrase, or clause that modifies—that is, gives information about—another word in the same sentence. For example, in the...
Read more >data-action - Stimulus Reference - Hotwire
If you need to support other keys, you can customize the modifiers using a custom schema. import { Application, defaultSchema } from "@hotwired/stimulus"...
Read more >Keyboard accelerators - Windows apps | Microsoft Learn
Accelerators are composed of two types of keys: modifiers and non-modifiers. Modifier keys include Shift, Menu, Control, and the Windows key ...
Read more >UI Copy: UX Guidelines for Command Names and Keyboard ...
Labels for commands should be brief, informative, rely on verbs and adjectives, and avoid branded terms. Command shortcuts must limit the ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yes
click.once->controller
was the initial syntax when we looked into this action options feature (https://github.com/hotwired/stimulus/pull/232) but we ended up withclick->controller#action:once
So we would :
:option
tokens.variation
token (probably only one in this case)Examples
Ahh, I had thought of click.once->controller, but what you’re proposing is even better, @adrienpoly. And yeah, the chaining seems very reasonable. Should still combine this with @NakajimaTakuya’s work on the hotkeys and mouse modifiers, so we could have
click.left->controller#vote:once
.