josefarias / hotwire_combobox

An accessible autocomplete for Ruby on Rails.
https://hotwirecombobox.com
MIT License
436 stars 26 forks source link

Add `icon`, basically a `handle` on the left and hidden:on-load #165

Closed RickHPotter closed 3 months ago

RickHPotter commented 3 months ago

My use-case is pretty simple. I just wanted to have an icon on the left.


![image](https://github.com/josefarias/hotwire_combobox/assets/36988302/0c891a4a-51fe-4de7-ad4c-2b028fbe8e20)

I wanted to mimic the render_in with a partial to the svg, but decided on just mimicking the handle.

This is my first time messing with some Open Source Code, I'm open to criticism.
josefarias commented 3 months ago

Hey @RickHPotter thanks for this PR, too

So, the reason we have markup for the handle (meaning its wrapping <span> element) is so that we have a place to use stimulus actions to listen for clicks; since we're using the handle to clear the query when the combobox has been typed in.

This wasn't always the case! In previous versions, the handle used to be CSS-only, rendered in an unwrapped :after pseudo-element.

Similarly, I think this han be achieved with CSS only. So I'd like to avoid adding a space for it in the library until we decide we want such an icon in our default design, and/or there's a compelling general use case for it at the library level.

So, because this should be already achievable by using CSS (let me know if not! I might be missing something) — I'm chalking this up to a design concern, not a library one. Closing for now.

You've found your way quite well in the library for your first time doing open source. I'd encourage you to keep going!