josefarias / hotwire_combobox

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

Bug report: menu item click does not fill input correctly #82

Closed kisp closed 6 months ago

kisp commented 6 months ago

Hi @josefarias, thank you for this very cool project! Very useful and a great resource to learn from :)

Adding this to my app today worked very smoothly. I am doing nothing too fancy. I am allowing the user to enter new text, though (not sure if this is relevant for the issue - I can try later).

What I am experiencing:

I enter a word into the input field that appears somewhere in the middle of the menu item value.

The search works perfectly: The menu gets narrowed down to that menu item.

Now, when I click in order to choose that menu item, my input field does not get updated to the total item text. Only to the substring (subword).

On the other hand: When I search for a menu item by a prefix, this does not happen. The entire item gets filled into the input field when I select it.

I was expecting this to happen for this case and also for the case above, which seems to me to be a bug.

PS: Sorry, I am on the road. Writing you from my mobile. Please let me know, if you need/want more detailed information. I can then write up more concrete steps to reproduce over the weekend.

josefarias commented 6 months ago

Hey @kisp. Thanks for the report!

I wasn't able to reproduce this but I might be missing something.

Are you able to reproduce on https://hotwirecombobox.com? If so, under which example and what did you write on the input?

If not, then you might want to check if you're running the latest version. What version are you running? Latest is v0.1.40.

Thanks!

josefarias commented 6 months ago

@kisp hey just reaching out again. Do you think you could provide a reliable reproduction? Trying to keep the issues list short, so asking before I close this out.

Anyone else experiencing this issue should also feel free to provide a reproduction.

Thanks!

josefarias commented 6 months ago

I think this might be the same thing as https://github.com/josefarias/hotwire_combobox/issues/93, please let me know if that matches what you're seeing or not. In the meantime, I'm gonna close this in favor of that other issue so we can continue the conversation there if it does match.

kisp commented 6 months ago

Hi @josefarias, sorry for being late.

The initial gif in issue #93 shows exactly what I was seeing.

The commit 2821994b31523ca7bb00318916a9573364f8cbbf "Fix clicking on async freetext substring matches" fixes it for me.

Just for completeness, I want to mention that I am not doing anything async. Whereas the test in that commit creates the combobox with options specified by the url/path helper movies_path(full_search: true), in my code, I pass in the options as an array of strings. Still, I need that commit as a fix.

josefarias commented 5 months ago

No worries! Glad that fixed it for you.

Ah, I'm surprised it was happening for non-async comboboxes. I had tried that and couldn't reproduce, that I can remember 🤔. In any case, if it's fixed for you then I think we're good to assume that commit is enough of a fix for now.

Thanks for writing in!