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

update aria-label screen reader handling for survey buttons #864

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions js/pages/myToDoList.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hideAnimation, questionnaireModules, storeResponse, isParticipantDataDestroyed, translateHTML} from "../shared.js";
import { hideAnimation, questionnaireModules, storeResponse, isParticipantDataDestroyed, translateHTML, translateText} from "../shared.js";
import { blockParticipant, questionnaire } from "./questionnaire.js";
import { renderUserProfile } from "../components/form.js";
import { consentTemplate } from "./consent.js";
Expand Down Expand Up @@ -402,7 +402,8 @@ const renderMainBody = (data, collections, tab) => {
const moduleTitle = modules[thisKey]['header'] || thisKey;
const isEnabled = modules[thisKey].enabled && !modules[thisKey].unreleased;
const buttonAction = modules[thisKey].unreleased ? 'mytodolist.comingSoon' : data[fieldMapping[modules[thisKey].moduleId]?.statusFlag] === fieldMapping.moduleStatus.started ? 'mytodolist.continue' : 'mytodolist.start';
const ariaLabelButton = `${buttonAction} ${moduleTitle}`;
const strippedModuleTitle = moduleTitle?.replace(/(\s|[-._\(\),])/g, '') || '';
const ariaLabelButton = translateText(buttonAction) + ' ' + translateText(`shared.mod${strippedModuleTitle}`);

started = true;
template += `
Expand All @@ -416,7 +417,7 @@ const renderMainBody = (data, collections, tab) => {
<div class="${modules[thisKey]['hasIcon'] === false? 'col-9':'col-md-8'}">
<p style="font-style:bold; font-size:24px; margin-left:10px">
<b style="color:#5c2d93; font-size:18px;">
<span data-i18n="${`shared.mod${moduleTitle.replace(/(\s|[-._\(\),])/g,'')}`}">${moduleTitle}</span>
<span data-i18n="${`shared.mod${strippedModuleTitle}`}">${moduleTitle}</span>
</b>
<br>
<span data-i18n="${modules[thisKey].description}"></span>
Expand All @@ -442,7 +443,10 @@ const renderMainBody = (data, collections, tab) => {
const moduleTitle = modules[key]['header'] || key;
const isEnabled = modules[key].enabled && !modules[key].unreleased;
const buttonAction = modules[key].unreleased ? 'mytodolist.comingSoon' : (data[fieldMapping[modules[key].moduleId].statusFlag] === fieldMapping.moduleStatus.started ? 'mytodolist.continue' : 'mytodolist.start');
const ariaLabelButton = `${buttonAction} ${moduleTitle}`;
const strippedModuleTitle = moduleTitle?.replace(/(\s|[-._\(\),])/g, '') || '';
const ariaLabelButton = translateText(buttonAction) + ' ' + translateText(`shared.mod${strippedModuleTitle}`);


template += `
<div class="w-95 mx-auto mb-3 border rounded" role="listitem" aria-label="${moduleTitle} details">
<div class="row">
Expand All @@ -454,7 +458,7 @@ const renderMainBody = (data, collections, tab) => {
<div class="${modules[key]['hasIcon'] === false ? 'col-9' : 'col-md-8'}">
<p style="font-style:bold; font-size:24px; margin-left:10px">
<b style="color:#5c2d93; font-size:18px;">
<span data-i18n="${`shared.mod${moduleTitle.replace(/(\s|[-._\(\),])/g,'')}`}">${moduleTitle}</span>
<span data-i18n="${`shared.mod${strippedModuleTitle}`}">${moduleTitle}</span>
</b>
<br>
<span data-i18n="${modules[key].description}"></span>
Expand Down