I am bulding the TailwindCSS combobox as a Phoenix Liveview LiveComponent (What’s with the capitals ).
When clicking inside the input element, the combobox opens and I can navigate the elements using ArrowUp/Down setting the select item in the LiveComponent’s state. However, the input element stays in focus and the active list item seems to be only artificial.
What I mean with artificial feeling is that when I hit enter, the enter event is taking place on the input element which remain in focus. Another thing which feels wrong is when an element is selected outside of the combobox popover the items is not inside focus and dissapears behind the overflow…
LiveView will never overwrite the input’s current value, even if it deviates from the server’s rendered updates
If I were you, I would do all of the client navigation (up, down, etc.) in just JS. when they select an item or hit enter, then send it to the LiveView.
For one, you won’t have the js/liveview source of truth collision. The second is that those server round trips are nice and snappy on local development, but are slower and feel slow once they are deployed to production.
Ok, thank you for the responses. Somehow I felt like 50% of the combobox was already doone and the path with LIveview only felt pretty good. I do understand the snappyness of this kind of interface would suffer from a roundtrip to the server.