Skip to content

a11y-click-events-have-key-events incorrectly repoted on <dialog> elements. #8283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tomprince opened this issue Feb 14, 2023 · 0 comments · Fixed by #15429
Closed

a11y-click-events-have-key-events incorrectly repoted on <dialog> elements. #8283

tomprince opened this issue Feb 14, 2023 · 0 comments · Fixed by #15429
Labels

Comments

@tomprince
Copy link

Describe the bug

By default, a dialog element shown via dialog.showModal() can be closed by pressing escape.

If I add an on:click handler to the dialog to enable clicking the background to dismiss it, I get an a11y-click-events-have-key-events warning on the dialog, despite being able to interact with the dialog via keyboard.

I wouldn't mind needing to explicitly disable the warning, but I can't just use

<!-- svelte-ignore a11y-click-events-have-key-events -->

as that also disables the warnings for all children of the dialog as well.

Reproduction

<script>
  let modal;
  const clickBackdrop = (event) => {
    if (event.target === modal) {
      close();
    }
  }
</script>

<button on:click={() modal.showModal()}>
	Open
</button>
<dialog bind:this={modal} style:overflow="none" on:click={clickBackdrop}>
  <div>
    <button on:click={() => modal.close()} >Close</button>
  </div>
</dialog>

<style>
  div {
    background-color: white;
    height: 3em;
    width: 6ch;
    padding: 1em;
  }
  dialog {
    border: 0;
    padding: 0;
  }
  dialog::backdrop {
    background-color: rgba(10, 10, 10, 0.86);
  }
</style>

Logs

No response

System Info

npmPackages:
    svelte: ^3.55.1 => 3.55.1 


### Severity

annoyance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants