Class: Shadcn::Combobox::ChipInput::Component
- Inherits:
-
Input::Component
- Object
- ViewComponent::Base
- ApplicationViewComponent
- Input::Component
- Shadcn::Combobox::ChipInput::Component
- Defined in:
- app/components/shadcn/combobox/chip_input/component.rb
Overview
The field that sits among the chips rather than inside an InputGroup: it takes whatever room is left on the last row.
Constant Summary
Constants inherited from ApplicationViewComponent
ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS
Instance Attribute Summary
Attributes inherited from Input::Component
#disabled, #placeholder, #show_clear, #show_trigger, #value
Attributes inherited from ApplicationViewComponent
Instance Method Summary collapse
-
#call ⇒ Object
No InputGroup and no addons: the chips box is the frame, and a chevron would have nowhere to sit.
-
#element_attributes(**defaults) ⇒ Object
This field has to carry its own name, and that is ours rather than upstream's — the same correction Select, Checkbox, Switch and the Combobox trigger each needed here.
Methods inherited from Input::Component
Methods inherited from ApplicationViewComponent
#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::Combobox::Input::Component
Instance Method Details
#call ⇒ Object
No InputGroup and no addons: the chips box is the frame, and a chevron would have nowhere to sit.
37 38 39 |
# File 'app/components/shadcn/combobox/chip_input/component.rb', line 37 def call render_element end |
#element_attributes(**defaults) ⇒ Object
This field has to carry its own name, and that is ours rather than upstream's — the same correction Select, Checkbox, Switch and the Combobox trigger each needed here.
It is not theoretical. The only name this input had was its
placeholder, and in multiple mode the controller blanks that once
there are chips — which upstream's own example also does. The field
was then a role="combobox" with no name at all, and axe failed it as
label, critical. Caught by the accessibility spec on the run after
the placeholder was wired up; the run before it could not see the
interaction, because nothing blanked the placeholder yet.
The caller's placeholder is used when there is one, because "Add a language…" names the field better than anything this gem could generate. Read at render time and never touched again, so the name stays put while the placeholder comes and goes.
31 32 33 |
# File 'app/components/shadcn/combobox/chip_input/component.rb', line 31 def element_attributes(**defaults) super(**{ "aria-label" => placeholder.presence || shadcn_t("combobox.add") }.merge(defaults)) end |