alpinejs / alpine

A rugged, minimal framework for composing JavaScript behavior in your markup.
https://alpinejs.dev
MIT License
27.92k stars 1.22k forks source link

UI x-radio: fix keyboard navigation when value of first/last radio option is null #4308

Open gdebrauwer opened 1 month ago

gdebrauwer commented 1 month ago

When the first or last x-radio:option has null as value, then keyboard navigation does not work correctly. It skips that option because it thinks that is already reached the end or beginning of the options array (caused by next || all[0] or prev || all.slice(-1)[0]). See screen recordings as a visual example.

https://github.com/user-attachments/assets/aa7cdeed-cf67-415b-b346-ab63b68296bc

https://github.com/user-attachments/assets/22d762b3-a1d0-4e6b-8a9a-43a4249bca3f