SonarQube 7.7 Community, SonarHTML 3.2 (build1615)
<button class="btn btn-outline-danger" (click)="cancel()">Cancel</button>
Recently upgraded to 7.7 and now seeing the bug Web:MouseEventWithoutKeyboardEquivalentCheck reported for some of our Angular 5 modules. For example the code above resulted in the bug “Add a ‘onKeyPress’ attribute to this tag.” and reviewing, I find the suggested compliant solution
<a onClick="doSomething();" onKeyPress="doSomething();" ...>
Is this rule valid for the given use case? Most (if not all) browsers already trigger the click event if the user hits the space-bar or enter key when focus is on a button. Further the suggested solution, if blindly followed would result in very unexpected behavior as the buttons are triggered when tabbing or arrowing around the page.