presleyd / alpinejs-select

83 stars 19 forks source link

First option in dropdown has a background attached to it even if it's not selected? #7

Open Cigoler opened 3 years ago

Cigoler commented 3 years ago

Trying to avoid using Select2, so I'm investigating this as a possible option. I'm assuming this isn't intentional and I'm doing something wrong but on my dropdowns the first item in the array is always highlighted (but not actually selected). If I select it it shows up as selected and the model data is updated but if I unselect it that first item in the list is still highlighted as though it was. Strange. I'm not super familiar with Livewire or Alpine, still trying to get to grips with them. If I change the Alpine code to have an option by default selected if it's null by default that shows up as selected in the list but again so does the first item in the list (just not as a bubble icon you can click off the input box).

presleyd commented 3 years ago

That is probably from my attempts to make it focusable and scrollable with arrow keys. There's a default index that starts with the first item on the list.

Im happy to dig back into this but I've been using slim select https://slimselectjs.com/ for the past few weeks to great success.

My Alpine select just has the advantage that you can update the value from the back end and sync it with the JS without firing an event.

On Fri, Jun 4, 2021, 5:53 PM Cigoler @.***> wrote:

Trying to avoid using Select2, so I'm investigating this as a possible option. I'm assuming this isn't intentional and I'm doing something wrong but on my dropdowns the first item in the array is always highlighted (but not actually selected). If I select it it shows up as selected and the model data is updated but if I unselect it that first item in the list is still highlighted as though it was. Strange. I'm not super familiar with Livewire or Alpine, still trying to get to grips with them. If I change the Alpine code to have an option by default selected if it's null by default that shows up as selected in the list but again so does the first item in the list (just not as a bubble icon you can click off the input box).

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/presleyd/alpinejs-select/issues/7, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACY6IXCLB3MFJBBQUOYEKITTRFDPJANCNFSM46DSRN7A .