Class: Shadcn::ContextMenu::Trigger::Component
- Inherits:
-
ApplicationViewComponent
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Shadcn::ContextMenu::Trigger::Component
- Defined in:
- app/components/shadcn/context_menu/trigger/component.rb
Overview
The area you right-click. Upstream gives it no classes at all (context-menu.tsx:19) — it is a region, not a control, and what it looks like is the caller's business.
A <span>, which is Radix's (Primitive.span, context-menu.tsx:151) and
not a detail: a <div> would be block where this is inline, so the same
markup would lay out differently. Measured on the live demo before it
was believed.
-webkit-touch-callout: none is Radix's too, and is the only reason a
long press on iOS does not raise the system menu over this one.
No aria-haspopup and no role: there is no keyboard route to a
context menu, and claiming one would promise something that does not
exist. Radix does not add either.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary collapse
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
- #element_attributes(**defaults) ⇒ Object
-
#initialize(disabled: false, **attributes) ⇒ Component
constructor
A new instance of Component.
Methods inherited from ApplicationViewComponent
#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name
Constructor Details
#initialize(disabled: false, **attributes) ⇒ Component
Returns a new instance of Component.
27 28 29 30 |
# File 'app/components/shadcn/context_menu/trigger/component.rb', line 27 def initialize(disabled: false, **attributes) @disabled = disabled super(**attributes) end |
Instance Attribute Details
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
25 26 27 |
# File 'app/components/shadcn/context_menu/trigger/component.rb', line 25 def disabled @disabled end |
Instance Method Details
#element_attributes(**defaults) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/shadcn/context_menu/trigger/component.rb', line 32 def element_attributes(**defaults) attributes = { style: merged_style("-webkit-touch-callout: none;"), "data-state" => "closed", "data-disabled" => (disabled.presence && ""), "data-shadcn--dropdown-menu-target" => "trigger" }.compact # A disabled trigger hands the gesture back to the browser rather than # swallowing it, which is Radix's own choice (`:158-161`): a region # that does nothing should not also take away the menu you expected. attributes["data-action"] = "contextmenu->shadcn--dropdown-menu#openAtPointer" unless disabled super(**attributes.merge(defaults)) end |