eslint-plugin-jsx-a11y icon indicating copy to clipboard operation
eslint-plugin-jsx-a11y copied to clipboard

[click-events-have-key-events] an example of click event which does not need to be accompanied by key event

Open gaurav5430 opened this issue 3 years ago • 1 comments

I have a div on click of which i just want to stop propagation of click event to its parent.

This is particularly useful in dropdown like widgets where clicking on the parent would open the dropdown child and clicking on the parent again would close the dropdown child. In this case, any click on the dropdown itself should not bubble to the parent (and close the dropdown)

To handle this, we add a click handler to the dropdown where we stop the event propagation. In this case, only the click event is required on the dropdown, there is no requirement for a key event as we do not have any functionality which needs to be exposed using the keyboard .

is this a valid case for ignoring the eslint rule click-events-have-key-events ?

Can it be an exception like this: https://github.com/jsx-eslint/eslint-plugin-jsx-a11y/blob/master/docs/rules/no-static-element-interactions.md#case-the-event-handler-is-only-being-used-to-capture-bubbled-events

gaurav5430 avatar Sep 04 '20 18:09 gaurav5430

:+1: also interested in an answer

theluk avatar Jul 26 '21 07:07 theluk