question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support for some other Action Options and Key Modifiers would be great

See original GitHub issue

This 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
adrienpolycommented, Mar 30, 2022

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 with click->controller#action:once

So we would :

  • describe event options with trailing :option tokens
  • filter events with .variation token (probably only one in this case)

Examples

# mixing event variant and event options
<div data-action="click.left->controller#vote:once:prevent">

# with global listener
<div data-action="keydown.left@window->tabs#prevTab">

1reaction
dhhcommented, Mar 30, 2022

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found