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

Fix svelte 4 warning #1635

Closed
wants to merge 1 commit into from
Closed

Fix svelte 4 warning #1635

wants to merge 1 commit into from

Conversation

punyflash
Copy link
Contributor

Copy link
Member

@jessarcher jessarcher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the warning is a false positive, and I don't think this is the right way to solve it.

Ideally, the Link component should always be used to render an <a> or <button>, which already comes with the correct role by default.

https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles/link_role#best_practices

Adding the role unnecessarily seems like it's against the best practices, and interestingly it goes against the a11y-no-redundant-roles rule.

Ideally, the warning would be smart enough to only appear if someone chooses to render something other than an a or button; in that case, it should be on them to add the correct role for their situation. I'm not sure whether this is possible, though.

Assuming that isn't possible, this might be an appropriate case for an ignore per https://svelte.dev/docs/accessibility-warnings. E.g:

<!-- svelte-ignore a11y-a11y-no-static-element-interactions -->

@@ -12,6 +12,8 @@
export let only = []
export let headers = {}
export let queryStringArrayFormat = 'brackets'
export let role = 'link'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could potentially be a "button" as well, right?

Comment on lines +41 to +42
{role}
{tabindex}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't these only be added if as is not a or button? Those already have the correct role by default.

@jessarcher jessarcher linked an issue Aug 16, 2023 that may be closed by this pull request
@pedroborges
Copy link
Collaborator

I agree with @jessarcher, just using the svelte-ignore rule should get rid of the warning. Please update and test your PR and I'll gladly approve it.

@punyflash punyflash mentioned this pull request Jan 30, 2024
@ingLomeland
Copy link

Whats the status on this PR? it fixes the issue with the ARIA warning on build in #1627

@driesvints
Copy link
Contributor

This PR seems to have stalled as the OP isn't answering anymore. It's best that someone else picks up the work in a new PR.

@Isaac-alencar
Copy link

This PR seems to have stalled as the OP isn't answering anymore. It's best that someone else picks up the work in a new PR.

I can take this one. I am struggling right now with this issue, so I can make the changes proposed by the original author.

@driesvints
Copy link
Contributor

We'd welcome a new PR for this. Thanks

@reinink
Copy link
Member

reinink commented Apr 16, 2024

Decided to fix this using a svelte-ignore as @jessarcher suggested (see #1858), and that has been released as part of v1.0.16 👍

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

Successfully merging this pull request may close these issues.

Svelte 4 warning during build
7 participants