SonarLint: Add a ‘onKeyPress|onKeyDown|onKeyUp’ attribute to this div tag.
In our case however there is a corresponding keyboard event (keyup.enter) to the mouse click-event, but it seems like it isn’t recognized by Sonar. While changing it to keydown.enter solves the Sonar issue, it isn’t an option for us out of accessibility concerns. Using just keyup and checking the keyCode also seems to work, but we’d have to sacrifice a convenient framework feature and change our code in many components for it to work.
Has anyone experienced this issue and found a solution for it?
From the point of view of accessibility, any component with role=button must be usable with both Enter and Space, just like a regular HTML button. (A screen reader user doesn’t hear the difference between a regular HTML button and <div role=button>, so behaviour must be consistent.)
Does the Sonar issue go away when you add a listener for Space?
Hello, I just got same false positive on Sonar 9.9.8. I would like to ask what is the progress on this problem and/or in which version is it integrated ?
I seen that ticket SONARHTML-251 did not progress since.
You’re right that there’s no progress on that Jira ticket. But even if there were, you wouldn’t see it in SonarQube 9.9.8, which is EOL and no longer being updated. Even if it weren’t, things like this don’t make it into LTA updates; only fixes for serious bugs and vulnerabilities.
I urge you to upgrade to a current version at your earliest convenience. Your upgrade path is: