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

Suggested Fix: [Image + Teaser] Don't require ALT text if no asset selected #2523 #2607

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -46,6 +46,7 @@
var altTextFromPage;
var altTextFromDAM;
var altCheckboxSelector = "coral-checkbox[name='./altValueFromDAM']";
var altIsDecorativeSelector = 'coral-checkbox[name="./isDecorative"]';
var altInputSelector = "input[name='./alt']";
var altInputAlertIconSelector = "input[name='./alt'] + coral-icon[icon='alert']";
var assetTabSelector = "coral-tab[data-foundation-tracking-event*='asset']";
Expand All @@ -65,7 +66,7 @@
$dialogContent = $dialog.find(dialogContentSelector);
var dialogContent = $dialogContent.length > 0 ? $dialogContent[0] : undefined;
if (dialogContent) {
isDecorative = dialogContent.querySelector('coral-checkbox[name="./isDecorative"]');
isDecorative = dialogContent.querySelector(altIsDecorativeSelector);

if ($(pageAltCheckboxSelector).length === 1) {
// when the tuple is used in the page dialog to define the featured image
Expand Down Expand Up @@ -170,8 +171,15 @@
validate: function() {
var seededValue = $(altInputSelector).attr("data-seeded-value");
var isAltCheckboxChecked = $(altCheckboxSelector).attr("checked");
var isDecorative = $(altIsDecorativeSelector).attr('checked');
var assetWithoutDescriptionErrorMessage = "Error: Please provide an asset which has a description that can be used as alt text.";
if (isAltCheckboxChecked && !seededValue) {

// Validate the following:
// - the image is not decorative
// - alt is not inherited from the DAM
// - the alt value is empty.
// If all of these are true, return a validation error
if (!isDecorative && !isAltCheckboxChecked && !seededValue) {
Copy link
Author

Choose a reason for hiding this comment

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

Another check that could be beneficial:

// Do we have an asset at all?
var isImageSelected = !!$('[name="./fileReference"]').val(); 

if (isImageSelected && !isDecorative && !seededValue)

return Granite.I18n.get(assetWithoutDescriptionErrorMessage);
}
}
Expand Down