Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pseudo events not supported with accessibility rule #888

Closed
edbzn opened this issue Sep 15, 2019 · 8 comments
Closed

Pseudo events not supported with accessibility rule #888

edbzn opened this issue Sep 15, 2019 · 8 comments

Comments

@edbzn
Copy link

edbzn commented Sep 15, 2019

Describe the bug

Hi, I would like to use accessibility rules as described here but they don't support pseudo events.

image

Context and configuration

Please share:

  • Which rule is causing the problem: template-click-events-have-key-events

Expected behavior

Support of pseudo events for accessibility rules.

Code

<a *ngFor="let name of groupNames"
    [class.selected]="name == selectedGroup.name"
    class="button mat-button filter-button"
    (click)="selectGroup(name)"
    (keyup.enter)="selectGroup(name)">{{name}}</a>
@lazarljubenovic
Copy link
Contributor

Since we're talking about accessibility, that thing's supposed to be a button, not an anchor.

@edbzn
Copy link
Author

edbzn commented Sep 15, 2019

@lazarljubenovic In this case selectGroup(name) does a redirection using the PlatformLocation API. IMO the <a> element is appropriate.

@lazarljubenovic
Copy link
Contributor

It's an anchor tag without href, which means it's a "placeholder for a link". Things like "Open in new tab" won't work. You should pre-compute the URL and then use routerLink.

@edbzn
Copy link
Author

edbzn commented Sep 16, 2019

@lazarljubenovic Ok noted, thanks for the advice.

However it doesn't resolve the main problem with pseudo events. Here is an other example without link element :

<div class="card-front" (click)="flipCard(person)" (keyup.enter)="flipCard(person)">
  <h3>{{person.name}}</h3>
</div>

The rule should cover this case as described here.

A non-interactive element that has a click event, should be accompanied by one of the key events (keyup, keydown or keypress)

But it fails when using pseudo events.

@lazarljubenovic
Copy link
Contributor

Yeah, sorry for side-tracking the topic 🙏 You're completely correct that it's a bug (or, well, a missing feature) in Codelyzer.

@mgechev
Copy link
Owner

mgechev commented Sep 16, 2019

@mohammedzamakhan do you think you can alter the rule template-click-events-have-key-events so we can handle this case?

@mohammedzamakhan
Copy link
Contributor

yes we can update it to handle it, I will take a look into it

@edbzn
Copy link
Author

edbzn commented Sep 20, 2019

Fixed in #893

@edbzn edbzn closed this as completed Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants