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

[no-noninteractive-element-interactions] <label/> should be able to accept event handlers #934

Closed
sangikhan29 opened this issue May 22, 2023 · 3 comments
Assignees

Comments

@sangikhan29
Copy link

sangikhan29 commented May 22, 2023

Similarly to the previous issue, but on a different rule, no-noninteractive-element-interactions should allow <label/> to accept event handlers like onClick. In this example, <label/> is used to shift focus to the <input/> upon click. So <label/> is not a non-interactive element.

Sometimes adding custom onClick is needed to support logging etc.

@sangikhan29
Copy link
Author

Hi @jessebeach, sorry to ping you right after dialog is resolved. But is there any update on this as well? Please let us know if there's something we can do to help!

@jessebeach
Copy link
Collaborator

Hello again @sangikhan29!

Sometimes adding custom onClick is needed to support logging etc.

This isn't something that this project can support. Any element could conceivably have a click handler added to it to support logging. I recommend either adding a suppression comment to suppress the warning or capture events for logging at the document rather than at each individual element.

Click handlers should be added to the control elements themselves, not the labels that describe them. If a label contains a control element, it will become clickable...this is something the browser client does automatically in this case.

@sangikhan29
Copy link
Author

Hi @jessebeach, thanks for looking into this! 🙏 I'll probably go ahead with suppressing existing ones but still enable to rule so that we can avoid similar cases in the future.

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

2 participants