Create HAML helper for simple single-select listbox dropdowns
We have a large number of dropdownlistbox elements in GitLab which amount to a simple, static list of options, often for sorting and filtering.
We ought to create a HAML/rails helper method to instantiate these in a way that will maintain functionality and design consistency with our Pajamas dropdowns.
The API will be a simple DOM helper method, e.g. gl_listbox_tag
with options to designate the options and their corresponding actions.
The underlying implementation can be one of several options. Among those discussed:
-
Render the DOM directly, mirroring the classes used in Pajamas, and utilizing bootstrap's native
data-toggle="dropdown"
property to handle the actual dropdown behavior. -
Render a simple DOM element with the options as data-attributes and implement a new javascript "behavior" which will notice the presence of the element, instantiate a Pajamas dropdown component, and mount it at its location using the provided options.
-
Render a simple DOM element with the options as data-attributes and add a script tag to the page which will load and execute the code necessary to make it function.
#348737 (comment 808527160) argues in favour of the third approach.
Implementation plan
-
Create the HAML and JS helpers, and delegate to GlDropdown
(technically not compliant, but available right now)