Closed jlw closed 6 months ago
Great catch @jlw thanks! I think this points to a larger problem in the codebase.
The current design couples certain things – like filtering and selection. Conditionals will keep proliferating unless we nip this in the bud.
I'm going to attempt a refactor I've had on the back burner for a while. That should fix this, as well as make our work in https://github.com/josefarias/hotwire_combobox/pull/106 easier. Although it might cause some minor merge conflicts. But we'll figure it out.
Gonna keep this open in case that refactor doesn't pan out. Working on it now.
@jlw I finished the refactor in https://github.com/josefarias/hotwire_combobox/pull/111. That should've also fixed the issues you're seeing here. Closing for now.
Sorry about the merge conflicts in the other PR. I'll help you get those sorted tomorrow.
While working on #108, I noticed some odd behavior around item selection that only manifested as a bug with the multiple selection. I simply added some extra conditionals in that PR because I hadn't yet worked out any clean fixes.
The first commit here addresses only the very first odd behavior - when I click on an option in the list, the first item is incorrectly selected before resolving on the actual option I clicked.
I verified this by adding the following:
which resulted in:
The second commit here addresses both of the de-selection and re-selection events, seen here originally in a bit more detail:
and now has been removed without breaking any system tests (and passing minimal manual testing):