CaptainCodeman / svelte-headlessui

HeadlessUI components for Svelte
https://captaincodeman.github.io/svelte-headlessui/
MIT License
564 stars 26 forks source link

Manage the active item via focus instead constant value #81

Open mu-hun opened 11 months ago

mu-hun commented 11 months ago

Manage the active item via focus

Most of the AGP documentation, including examples you to manage the keyboard & mouse active item as the focus.

I suggest to change styling at the CSS selectors level if possible, rather than manipulating the styles on the JS side in the examples.

Updated example list

Unfortunately, I made it a Draft PR because there is problem at keyboard interaction between Combobox items.

CaptainCodeman commented 11 months ago

Thanks for this.

Yeah, I generally think styling based on aria attributes is always better as it helps make them a first-class feature more than an add-on. The original idea was to try to have parity with the official headless lib when it came to the actual HTML & CSS.

The aria-activedescendant option looks better than roving tab index as it seems to cater for having selected + focus be different things, but I read an article that suggested it wasn't consistent across browsers. I was planning on exploring if that was still the case and possibly using it with the next version (Svelte-5 / Runes).