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(a11y): add missing alternative texts #1143

Merged
merged 3 commits into from
Oct 8, 2023

Conversation

d-koppenhagen
Copy link
Contributor

  • provide alt attributes for <image> elements. Usealt="" for decorative images
  • add HiddenText component for icon button usage. The component uses the WindiCSS class src-only to correctly hide elements visually but read texts out for screen readers

closes #1142

- provide `alt` attributes for `<image>` elements. Use`alt=""` for decorative images
- add `HiddenText` component for icon button usage. The component uses the WindiCSS class `src-only` to correctly hide elements visually but read texts out for screen readers

closes slidevjs#1142
@@ -157,6 +158,7 @@ watchEffect(() => {
</div>
</Transition>
<button v-if="value" class="fixed text-2xl top-4 right-4 slidev-icon-btn text-gray-400" @click="close">
<HiddenText text="Close" />
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if in this case, would a title to the button would be more straightforward?

Copy link
Contributor Author

@d-koppenhagen d-koppenhagen Oct 7, 2023

Choose a reason for hiding this comment

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

I think the title attribute isn't the best way to make things more accessible (even if at the first look, I thought the same). See for example: https://www.a11yproject.com/posts/title-attributes/#:~:text=Short%20answer%3A%20Don't%20use,and%20possibly%20not%20even%20used.

It could be tackled with aria attributes as well, but there are also some older screenreaders and browser caught IE 😃 having problems with hidden elements.
The CSS trick is a pretty old but effective one which should work for almost every device and browser.

@antfu
Copy link
Member

antfu commented Oct 8, 2023

Thanks!

@antfu antfu merged commit 4cc65b2 into slidevjs:main Oct 8, 2023
8 checks passed
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.

a11y: Icon-buttons do not have an accessible name
2 participants