Class: PhlexKit::ComboboxList

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/combobox/combobox_list.rb

Overview

Scrollable option list in a PhlexKit::ComboboxPopover. Carries the listbox role and an id the controller points the combobox element's aria-controls at (and derives option ids from). See combobox.rb.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(id: nil, **attrs) ⇒ ComboboxList

id: is a named kwarg (not left in **attrs) because mix would merge a caller id with the generated one into an invalid two-token id, breaking aria-controls (the documented list_id: wiring) and derived option ids.



9
10
11
12
# File 'app/components/phlex_kit/combobox/combobox_list.rb', line 9

def initialize(id: nil, **attrs)
  @id = id || "pk-combobox-list-#{SecureRandom.hex(4)}"
  @attrs = attrs
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
# File 'app/components/phlex_kit/combobox/combobox_list.rb', line 14

def view_template(&)
  div(**mix({
    id: @id,
    class: "pk-combobox-list",
    role: "listbox",
    data: { phlex_kit__combobox_target: "list" }
  }, @attrs), &)
end