Hello,
since a couple of days the HTML analysis of our Angular 17 application fails with an unfulfilled S1082 Mouse events should have corresponding keyboard events concerning interactive <div>
elements:
<div role="button"
tabindex="0"
(click)="clear()"
(keyup.enter)="clear()"
class="reset">
Reset
</div>
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?