Module: LocoMotion::Concerns::ActionableComponent

Extended by:
ActiveSupport::Concern
Defined in:
lib/loco_motion/concerns/actionable_component.rb

Overview

Can be included in linkable components to provide a first-class action keyword option — Stimulus data-action sugar — instead of hand-writing the nested html: { data: { action: ... } } hash. This mirrors the way TurboableComponent sugars the data-turbo-* attributes, and is pulled in for every linkable component by LinkableComponent.

Option Emitted attribute
action data-action

Stimulus infers the click event for both <button> and <a>, so action: "my-controller#handle" is shorthand for action: "click->my-controller#handle". The attribute is only emitted when action is provided, and anything passed explicitly via html: { data: { action: ... } } still takes precedence (user HTML is deep-merged over this default).

The attribute is written in the nested data: { action: ... } form (not a flat "data-action" key) so it deep-merges cleanly alongside the data-controller and data-turbo-* attributes other concerns add to the same element, rather than colliding into a duplicate attribute.