Skip to content

Commit

Permalink
Use different verb for link text versus image text, but use custom al…
Browse files Browse the repository at this point in the history
…t text for both
  • Loading branch information
bbpennel committed Dec 6, 2024
1 parent 404c154 commit 2ed0483
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
19 changes: 12 additions & 7 deletions static/js/vue-cdr-access/src/components/full_record/thumbnail.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<router-link :to="linkToPath" :title="tooltip" :aria-label="ariaText" class="thumbnail" :class="imgClasses">
<router-link :to="linkToPath" :title="tooltip" :aria-label="linkAltText" class="thumbnail" :class="imgClasses">
<div v-if="src !== ''" :style="{ 'background-image': 'url(' + objectData.thumbnail_url + ')'}"
:aria-label="altText"
:aria-label="imageAltText"
role="img"
class="thumbnail-viewer"
:class="{restricted: markedForDeletion(objectData) || isRestricted(objectData)}"></div>
Expand Down Expand Up @@ -53,15 +53,20 @@ export default {
if (!text) {
text = this.objectData.title;
}
return `Thumbnail for ${text}`;
return text;
},
objectData() {
return this.permissionData(this.thumbnailData);
imageAltText() {
return `Thumbnail for ${this.altText}`;
},
ariaText() {
return `Visit ${this.objectData.title}`
linkAltText() {
return `Visit ${this.altText}`;
},
objectData() {
return this.permissionData(this.thumbnailData);
},
badgeIcon() {
Expand Down
6 changes: 5 additions & 1 deletion static/js/vue-cdr-access/tests/unit/thumbnail.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ describe('thumbnail.vue', () => {
expect(wrapper.find('.thumbnail .thumbnail-viewer').exists()).toBe(true);
expect(wrapper.find('i.placeholder').exists()).toBe(false);
expect(wrapper.find('a').attributes('class'))
.toEqual('thumbnail thumbnail-size-large has_tooltip')
.toEqual('thumbnail thumbnail-size-large has_tooltip');
let linkText = wrapper.find('a').attributes('aria-label');
expect(linkText).toBe('Visit testCollection');
let altText = wrapper.find('.thumbnail .thumbnail-viewer').attributes('aria-label');
expect(altText).toBe('Thumbnail for testCollection');
});
Expand All @@ -142,6 +144,8 @@ describe('thumbnail.vue', () => {
updatedRecordData.briefObject.altText = 'Custom alt text';
await wrapper.setProps({ thumbnailData: updatedRecordData });
expect(wrapper.find('.thumbnail .thumbnail-viewer').exists()).toBe(true);
let linkText = wrapper.find('a').attributes('aria-label');
expect(linkText).toBe('Visit Custom alt text');
let altText = wrapper.find('.thumbnail .thumbnail-viewer').attributes('aria-label');
expect(altText).toBe('Thumbnail for Custom alt text');
});
Expand Down

0 comments on commit 2ed0483

Please sign in to comment.