Skip to content

Commit

Permalink
List accessibility for quiz-marquee (#3460)
Browse files Browse the repository at this point in the history
* List accessibility for quiz-marquee
<!-- Before submitting, please review all open PRs. -->

* Update quiz-marquee authoring to denote nested lists
* roles for list and listitem in quiz-marquee and quiz-results

Resolves: [MWPW-165027](https://jira.corp.adobe.com/browse/165027-NUMBER)

* PR feedback
  • Loading branch information
colloyd authored Jan 14, 2025
1 parent 2d5b5bf commit c58ef7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libs/blocks/quiz-marquee/quiz-marquee.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,13 @@ export default async function init(el) {
[...rows].forEach(async (row) => {
const cols = row.querySelectorAll(':scope > div');
const isFragRow = cols[0].textContent.trim() === 'nested-fragments';
const isList = cols[2]?.textContent?.trim() === 'list' || false;

if (isFragRow) {
cols[0].parentElement.classList.add('nested', cols[1].textContent.trim());
const fragParent = cols[0].parentElement;
fragParent?.classList.add('nested', cols[1]?.textContent?.trim());
if (isList) fragParent.setAttribute('role', 'list');

const wrapper = createTag('div', { class: 'copy-wrapper' });
row.append(wrapper);
wrapper.append(...cols);
Expand Down
1 change: 1 addition & 0 deletions libs/blocks/quiz-results/quiz-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function loadFragments(el, experiences) {
}
document.querySelectorAll('main > div, .quiz-results').forEach((quiz) => quiz.removeAttribute('daa-lh'));
document.querySelectorAll('.quiz-results.basic > .fragment > .section').forEach((section, idx) => decorateSectionAnalytics(section, idx, getConfig()));
if (el.getAttribute('role') === 'list') document.querySelectorAll('.nested[role=list] > .fragment').forEach((fragment) => fragment.setAttribute('role', 'listitem'));
}

function redirectPage(quizUrl, debug, message) {
Expand Down

0 comments on commit c58ef7d

Please sign in to comment.