josefarias / hotwire_combobox

An accessible autocomplete for Ruby on Rails.
https://hotwirecombobox.com
MIT License
496 stars 32 forks source link

Fix interactivity of listbox options when combobox is in a dialog #197

Closed JoshAntBrown closed 1 month ago

JoshAntBrown commented 2 months ago

Resolves #196

It appears that most browsers won't allow the listbox options to receive any pointer events unless they are also focusable.

We probably don't actually want the listbox options to receive focus through the tab sequence, since this would be in conflict with the combobox pattern as described by W3: https://www.w3.org/WAI/ARIA/apg/patterns/combobox/

Note: The popup indicator icon or button (if present), the popup, and the popup descendants are excluded from the page Tab sequence.

Fortunately, it seems setting a tabindex of -1 on the options satisfies both parts.

josefarias commented 1 month ago

@JoshAntBrown thanks for a great bug report, and an immediate fix! Really appreciate your thoroughness here.

I've added a test, and made an inconsequential cosmetic change to match other tabindex attrs defined elsewhere in the library.

Gotta leave for the day, but I plan to merge this tomorrow once CI is green.

Thanks again!