Class: Shadcn::Select::List::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/select/list/component.rb

Overview

Where the options live once a search field shares the popover.

In the plain select the listbox role sits on SelectContent itself. It cannot when a text field is in there too: a textbox is not an allowed child of a listbox, and axe reports aria-required-children — critical — for exactly that shape. shadcn's aria variant splits them the same way.

Classes are that variant's verbatim, except p-1 for its p-0: the padding this port keeps on the viewport moves here, because the viewport now holds the search field too.

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#call, #css_classes, default_tag, #initialize, #merged_style, #render_element, #shadcn_t, slot_name, #style_variants, #tag_name

Constructor Details

This class inherits a constructor from Shadcn::ApplicationViewComponent

Instance Method Details

#element_attributes(**defaults) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/components/shadcn/select/list/component.rb', line 25

def element_attributes(**defaults)
  # A named listbox, because an unnamed one is an
  # `aria-input-field-name` violation — serious, and WCAG rather than
  # best-practice. The dialog around it is named separately, so a
  # screen reader announces the popover and then the list rather than
  # the same words twice. shadcn's aria variant names both too.
  super(**{
    role: "listbox",
    "data-action" => "scroll->shadcn--select#syncScrollButtons",
    "aria-label" => shadcn_t("select.list_label"),
    "data-shadcn--select-target" => "list"
  }.merge(defaults))
end