Eslint-plugin-jsx-a11y: no-noninteractive-element-interactions rule is triggered with onSubmit event

Created on 1 Jun 2017  路  9Comments  路  Source: jsx-eslint/eslint-plugin-jsx-a11y

With this example the rule triggers an error:

<form onSubmit={ this.handleSubmit }>
</form>
bug help wanted

All 9 comments

I'm experiencing this issue with iframe and onLoad.

The rule description suggests that the rule only applies to mouse and keyboard event listeners, but this doesn't seem to be the case in practice:

Non-interactive elements should not be assigned mouse or keyboard event listeners.

onSubmit is both a mouse and keyboard event listener.

onLoad, I agree should be allowed on img, iframe, and body tags.

Throwing my two cents about the form: I don't see any accessibility bad practice in @fernandopasik's example. What about the reset event, or events that bubble up like change (I think)? Predicting whether a developer uses these events in a non-accessible manner seems way out of scope. I feel like the term "interactions" should only cover what browsers call "user gestures" (the gestures a browser requires to allow the use of some APIs, like the Full Screen API). If I'm not mistaken, these are simply mouse and keyboard events.

I thought onSubmit and onReset are form events, not keyboard nor mouse events. @ljharb please could you share documentation regarding this?

They could be triggered indirectly by keyboard or mouse events on separate html elements.

As @axelboc said, why would be non accessible to listen to these form events in the form element? It's not that I'm listening form elements in a div or any other non interactive element.

@fernandopasik you're right, they're form events, but form events result from user interaction (keyboard and/or mouse), so conceptually they apply here.

That said, I totally agree that onSubmit makes sense on <form> (and only on <form>), which is why I added the "bug" label immediately :-)

@ljharb oh I'm sorry, I didn't notice the bug label! Thanks!

Agree. Good points. Will update the rule.

Fixed as of #281

Was this page helpful?
0 / 5 - 0 ratings