eslint-plugin-jsx-a11y: No Static Element Interactions failing.

I’m seeing the linter fail on this case, which I don’t quite understand:

      <div
        {...this.props}
        role={this.props.role}
        onKeyPress={e => this.handleKeyPress(e)}
      >
        {this.props.children}
      </div>

Am I missing something, or is this a false positive? (FWIW, role has a default value of button, so unless someone were to be really explicitly bad, this should always have a reasonable role value.)

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 19 (3 by maintainers)

Most upvoted comments

@ljharb, I am having the same issue as @Luchanso: the example doesn’t pass when no-static-element-interactions is enabled; using the role attribute does not work.

I’m getting an error on this rule, even when assigning a role. Using version 6.0.3.

image

Thanks, version 6 looks like it fixes the issue!

Yep, it’s not work I was try:

<div className="foo" onClick={() => {}} role="button" />