Best way to listen for when an option is selected? #97
-
Me again sorry, I was reading the custom event emitter and looking in the source code, i can only see an event emitted being "dispatch("hw-combobox:selection", { target: this.element, detail })" in events.js but it's emitted on every key stroke, not just when an option is selected, what's the best way to listen for when an option is selected? currently i have: <%= pi.combobox :product_variant_id, search_product_variants_products_path, placeholder: "Search products", data: { action: "hw-combobox:selection->form#submit" } %> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 9 replies
-
Ah good observation. That's because hotwire_combobox autoselects the first option that's visible as you type! I think we could emit a different event when the combobox is closed that would fit your needs. |
Beta Was this translation helpful? Give feedback.
@timmyd87 funny you should mention it... Just merged #100!
Please point your gem to the main branch and try it out. Let me know if you run into trouble. Closing for now.