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

Shs 5134 photo album aria #1404

Merged
merged 4 commits into from
Dec 5, 2023
Merged

Conversation

mndonx
Copy link
Contributor

@mndonx mndonx commented Nov 22, 2023

READY FOR REVIEW

Summary

This PR makes adjustments to how the colorbox gallery pulls in attributes for identifying link purposes.

Urgency

medium

Steps to Test

  1. Visit an example page with a Photo Gallery like http://hs-colorful.suhumsci.loc/components/photo-album
  2. The thumbnail gallery images should be links. In the markup, the links should have an aria-title attribute. This attribute should be (in this order): the alt text of the image if it isn't blank, the caption if it isn't blank, or generic text "Thumbnail Image" if neither of those exist.

I realize this strays from the original AC. But I'm realizing that the problem here is that the aria-title exists because sometimes the images don't have alt text. And that's a problem for describing the to the user what they are clicking on and why. At the same time, there's some sort of bug with the colorbox templates where even if there's no alt text on the image, it pulls in some weird additional markup ({"alt":""} or something like that), so there won't ever be an error saying "hey, there's no alt text here."

I tried to approach this with giving best to worst aria-title text possible to the link. Maybe the generic text could be improved. Please let me know what you think!

PR Checklist

@mndonx mndonx requested a review from cienvaras November 22, 2023 06:41
@cienvaras cienvaras changed the base branch from develop to fk-stnfd-sprint-39 November 23, 2023 19:30
Copy link
Collaborator

@cienvaras cienvaras 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 this approach works, but there are a couple of things that can be improved:

  1. The variable attributes['data-cbox-img-attrs'] is a JSON string, it contains special chars and extra text that is included in the alt text and read by the screen reader. This can confuse end users:
    Screenshot 2023-11-23 at 14 17 04

    It should be possible to parse this string and extract the alt text itself.

  2. I think that the labels can be more descriptive. The purpose of the links is not clear, there's not descriptive text anywhere indicating that this is a gallery. While this is also a content issue, we could create links that provide a better description of the purpose. For example instead of adding just the alt text in the aria-label, we could set the text to be "Open [ALT] image in the gallery" (or something similar). We could just use "Open image in the gallery" for images without an alt text.

Also, it would be good to check with Tori if the goal is to have users to set correct alt text for all images. Editoria11y reports the missing alt texts, but only if the aria-label is not present. Maybe it would be better to leave the aria-label out and use the error report as an incentive for editors to fix all the missing alt texts.

@mndonx
Copy link
Contributor Author

mndonx commented Nov 27, 2023

@cienvaras I've made those changes -- should I ask Tori about her preference now or after we send them the changes to review?

@mndonx mndonx requested a review from cienvaras November 27, 2023 19:14
@mndonx
Copy link
Contributor Author

mndonx commented Nov 27, 2023

Also, I removed the "caption/credit" possibility. Describing what will happen if clicked seems to trump a description that might end up just being a photo credit.

Base automatically changed from fk-stnfd-sprint-39 to 10.0.5-release November 27, 2023 23:46
@mndonx mndonx requested a review from aasarava November 28, 2023 03:26
{% set link_label = "Open " ~ attributes['data-cbox-img-attrs'] ~ " image in the gallery" %}
{% endif %}
{% set link_label = link_label|raw %}
{% set link_label = link_label|replace({'{"alt":"':'', '"}':''}) %}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This works, but checking the colorbox module code I found that data-cbox-img-attrs can include more attributes, not only alt. To prevent weird values, you can get the alt text from the image variable:

{% set alt_text = image['#alt'] %}

That would also make the use of the |raw filter unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh my, you are right, we don't need that stuff anymore. Thanks!

@mndonx mndonx requested a review from cienvaras December 1, 2023 22:54
Copy link
Collaborator

@cienvaras cienvaras left a comment

Choose a reason for hiding this comment

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

Works great, thanks!

@cienvaras cienvaras changed the base branch from 10.0.5-release to fk-stnfd-sprint-40 December 5, 2023 15:31
@cienvaras cienvaras merged commit 915dbe3 into fk-stnfd-sprint-40 Dec 5, 2023
1 check failed
@cienvaras cienvaras deleted the SHS-5134-photo-album-aria branch December 5, 2023 15:33
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.

3 participants