metonym / svelte-typeahead

Accessible, fuzzy search typeahead component
https://metonym.github.io/svelte-typeahead
MIT License
222 stars 18 forks source link

Search results don't have on:keydown, on:keyup, or on:keypress events and it triggers an A11y warning #66

Closed idheepan closed 1 year ago

idheepan commented 1 year ago

I get the warning svelte-typeahead/src/Typeahead.svelte:233:8 A11y: visible, non-interactive elements with an on:click event must be accompanied by an on:keydown, on:keyup, or on:keypress event. wherever I use svelte-typeahead with svelte version 3.52.0

Workaround: Suppress the warning using <!-- svelte-ignore a11y-click-events-have-key-events --> for each of the result list item.

   {#if showResults}
      {#each results as result, index}
      <!-- svelte-ignore a11y-click-events-have-key-events -->
        <li
          role="option"
          id="{id}-result-{index}"
          class:selected={selectedIndex === index}
          class:disabled={result.disabled}
...

If that workaround is good enough to be a solution for now, I can send a pull request.

metonym commented 1 year ago

PR welcome.

metonym commented 1 year ago

Thanks for reporting this.

The a11y warnings have been silenced in v4.4.0. a11y-click-events-have-key-events is a false positive; the other warning is ignored but tracked in #72.