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

Add role to empty links #810

Merged
merged 2 commits into from
Oct 22, 2021
Merged

Add role to empty links #810

merged 2 commits into from
Oct 22, 2021

Conversation

kmeleta
Copy link
Contributor

@kmeleta kmeleta commented Oct 21, 2021

Why are these changes introduced?

Fixes #387

What approach did you take?

Disabled/empty links should have aria-disabled="true" and role="link" instead of a href. I found image-banner, image-with-text, and rich-text needed the role. I didn't find any other areas where we render links with no href.

Demo links

Checklist

@kmeleta kmeleta requested a review from svinkle October 21, 2021 16:46
@svinkle
Copy link
Member

svinkle commented Oct 21, 2021

@kmeleta Also check multicolumn.

@kmeleta
Copy link
Contributor Author

kmeleta commented Oct 21, 2021

Also check multicolumn.

@svinkle the section link for multicolumn appeared to already have the proper attributes. I'll make sure the new column specific links we're adding in the other PR have the same as well.

If you think of anywhere else I might check though definitely let me know.

svinkle
svinkle previously approved these changes Oct 21, 2021
@ludoboludo ludoboludo self-requested a review October 21, 2021 20:08
LucasLacerdaUX
LucasLacerdaUX previously approved these changes Oct 21, 2021
Copy link
Contributor

@LucasLacerdaUX LucasLacerdaUX left a comment

Choose a reason for hiding this comment

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

Looks good to me. Just left a code style suggestion if you think it makes sense :P

@@ -93,10 +93,10 @@
{%- when 'buttons' -%}
<div class="banner__buttons{% if block.settings.button_label_1 != blank and block.settings.button_label_2 != blank %} banner__buttons--multiple{% endif %}" {{ block.shopify_attributes }}>
{%- if block.settings.button_label_1 != blank -%}
<a{% if block.settings.button_link_1 != blank %} href="{{ block.settings.button_link_1 }}"{% endif %} class="button{% if block.settings.button_style_secondary_1 %} button--secondary{% else %} button--primary{% endif %}"{% if block.settings.button_link_1 == blank %} aria-disabled="true"{% endif %}>{{ block.settings.button_label_1 | escape }}</a>
<a{% if block.settings.button_link_1 == blank %} role="link" aria-disabled="true"{% else %} href="{{ block.settings.button_link_1 }}"{% endif %} class="button{% if block.settings.button_style_secondary_1 %} button--secondary{% else %} button--primary{% endif %}">{{ block.settings.button_label_1 | escape }}</a>
Copy link
Contributor

Choose a reason for hiding this comment

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

Just a pattern we can apply here.

Since there's always going to be something being outputted by this condition, we can move the whitespace before the {% if %}.

Suggested change
<a{% if block.settings.button_link_1 == blank %} role="link" aria-disabled="true"{% else %} href="{{ block.settings.button_link_1 }}"{% endif %} class="button{% if block.settings.button_style_secondary_1 %} button--secondary{% else %} button--primary{% endif %}">{{ block.settings.button_label_1 | escape }}</a>
<a {% if block.settings.button_link_1 == blank %}role="link" aria-disabled="true"{% else %}href="{{ block.settings.button_link_1 }}"{% endif %} class="button{% if block.settings.button_style_secondary_1 %} button--secondary{% else %} button--primary{% endif %}">{{ block.settings.button_label_1 | escape }}</a>

This would apply to every change in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yeah good observation, I'm not sure I feel too strongly about it though. I think I'd have to either move the class attr in front of the others or put it on a new line or else risk a double space. So I don't feel we're gaining much from it.

Copy link
Contributor

@ludoboludo ludoboludo left a comment

Choose a reason for hiding this comment

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

Looks good!

I think one other place it could be added is in the collection-list.liquid for:

<a{% if block.settings.collection != blank and block.settings.collection.all_products_count > 0 %} href="{{ block.settings.collection.url }}"{% endif %}
            class="card animate-arrow link{% if block.settings.collection.featured_image != blank %} card--media{% else %}{% if section.settings.image_ratio != 'adapt' %} card--stretch{% endif %}{% endif %}{% unless section.settings.image_padding %} card--light-border{% endunless %}"
          >

@kmeleta kmeleta dismissed stale reviews from LucasLacerdaUX and svinkle via ce6663f October 21, 2021 20:42
@kmeleta kmeleta merged commit 485e279 into main Oct 22, 2021
@kmeleta kmeleta deleted the disabled-links-role branch October 22, 2021 14:26
@kmeleta kmeleta mentioned this pull request Oct 22, 2021
5 tasks
@andrewetchen andrewetchen mentioned this pull request Feb 4, 2022
9 tasks
phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
* Add role to empty links

* Also collection list
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.

[Global] Disabled links are still actionable
4 participants