From f837a8430cdbf7a6d85155f8cfebeb31e55d3226 Mon Sep 17 00:00:00 2001 From: Oliver Tacke Date: Fri, 13 Sep 2024 17:17:01 +0200 Subject: [PATCH] Fix aria label of image expand/collapse button --- scripts/question.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/scripts/question.js b/scripts/question.js index 212a68c..387731c 100644 --- a/scripts/question.js +++ b/scripts/question.js @@ -967,12 +967,16 @@ H5P.Question = (function ($, EventDispatcher, JoubelUI) { } const setAriaLabel = () => { - const ariaLabel = $imgWrap.attr('aria-expanded') === 'true' - ? options.minimizeImage + let ariaLabel = $imgWrap.attr('aria-expanded') === 'true' + ? options.minimizeImage : options.expandImage; - - $imgWrap.attr('aria-label', `${ariaLabel} ${options.alt}`); - }; + + if (options.alt) { + ariaLabel = `${ariaLabel} ${options.alt}`; + } + + $imgWrap.attr('aria-label', ariaLabel); + }; var sizeDetermined = false; var determineSize = function () {