josefarias / hotwire_combobox

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

Implement custom events #75

Closed josefarias closed 6 months ago

josefarias commented 6 months ago

This adds a hw-combobox:selection custom event, the details of which describe the status of the combobox.

This also introduces a new feature where if the combobox value is unjustifiably blank (i.e. no blank option is selected but the value is empty), then we clear the query. In line with https://github.com/josefarias/hotwire_combobox/discussions/70, and also aligns well with the ergonomics of being able to expect an hw-combobox:selection event every time the hidden field value changes.

Finally, this also fixes a bug in the memoization of canonical_id, adds the missing .hw-combobox__input--invalid CSS class, and more completely adjusts validity in all comboboxes.