diff --git a/.github/workflows/data-processing.yml b/.github/workflows/data-processing.yml index 0a1d8c15a2b..fcbab416775 100644 --- a/.github/workflows/data-processing.yml +++ b/.github/workflows/data-processing.yml @@ -565,6 +565,7 @@ jobs: !data/partners.json !data/publications.yaml static/data/ + !static/data/open_research_games.json static/partials/ static/newsletters/ content/contributor-analysis/ @@ -662,6 +663,11 @@ jobs: if [ -f /tmp/generated-resources/static/data/fred_citation.txt ]; then cp /tmp/generated-resources/static/data/fred_citation.txt static/data/fred_citation.txt fi + # Remove retired stale static games JSON (#1151); the portal now builds from data/open_research_games.json. + git rm -f --ignore-unmatch static/data/open_research_games.json || { + rm -f static/data/open_research_games.json + git add -A -- static/data/open_research_games.json + } if [ -f /tmp/generated-resources/summaries.json ]; then cp /tmp/generated-resources/summaries.json data/summaries.json fi diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml index 60f85263b7a..050dbae294a 100644 --- a/.github/workflows/deploy.yaml +++ b/.github/workflows/deploy.yaml @@ -209,6 +209,8 @@ jobs: # ======================= - name: Build site run: | + # Drop retired static/data/open_research_games.json if an older data-artifact unpacked it (#1151). + rm -f static/data/open_research_games.json hugo --gc --minify --cleanDestinationDir --destination public env: HUGO_ENV: production diff --git a/assets/js/doors/steering.js b/assets/js/doors/steering.js index b7dcab244bd..f32eceaae08 100644 --- a/assets/js/doors/steering.js +++ b/assets/js/doors/steering.js @@ -25,19 +25,26 @@ document.querySelectorAll('#strategic .sc-title-card').forEach((card) => { if (area) card.dataset.area = area[1]; }); +window.__scManaged = true; let trigger = null; const backdrops = [...document.querySelectorAll('.sc-modal-backdrop')]; backdrops.forEach((backdrop) => { const name = backdrop.querySelector('.sc-modal-name'); - backdrop.setAttribute('role', 'dialog'); - backdrop.setAttribute('aria-modal', 'true'); + if (!backdrop.getAttribute('role')) backdrop.setAttribute('role', 'dialog'); + if (!backdrop.getAttribute('aria-modal')) backdrop.setAttribute('aria-modal', 'true'); if (name) { name.id = name.id || `${backdrop.id}-name`; - backdrop.setAttribute('aria-labelledby', name.id); + if (!backdrop.getAttribute('aria-labelledby')) backdrop.setAttribute('aria-labelledby', name.id); + } + const closeBtn = backdrop.querySelector('.sc-close-btn'); + if (closeBtn) { + if (!closeBtn.hasAttribute('type')) closeBtn.setAttribute('type', 'button'); + if (!closeBtn.getAttribute('aria-label')) closeBtn.setAttribute('aria-label', 'Close profile'); + closeBtn.querySelector('svg')?.setAttribute('aria-hidden', 'true'); } - backdrop.querySelector('.sc-close-btn')?.setAttribute('aria-label', 'Close this profile'); backdrop.querySelectorAll('.sc-social-links a').forEach((link) => { + link.querySelector('svg')?.setAttribute('aria-hidden', 'true'); if (!link.getAttribute('aria-label')) { const host = new URL(link.href, location.href); link.setAttribute('aria-label', host.protocol === 'mailto:' ? 'Email' : host.hostname.replace(/^www\./, '')); @@ -46,25 +53,52 @@ backdrops.forEach((backdrop) => { }); document.querySelectorAll('.sc-card[onclick]').forEach((card) => { - const name = card.querySelector('.sc-card-name'); - card.setAttribute('role', 'button'); - card.tabIndex = 0; - card.setAttribute('aria-label', `Open the profile of ${name ? name.textContent.trim() : 'this person'}`); - card.addEventListener('click', () => { trigger = card; }); - card.addEventListener('keydown', (event) => { - if (event.key === 'Enter' || event.key === ' ') { - event.preventDefault(); - card.click(); + const isButton = card.tagName === 'BUTTON'; + if (!card.getAttribute('aria-haspopup')) card.setAttribute('aria-haspopup', 'dialog'); + if (!isButton) { + const name = card.querySelector('.sc-card-name')?.textContent.trim(); + const role = card.querySelector('.sc-card-role')?.textContent.trim(); + card.setAttribute('role', 'button'); + card.tabIndex = 0; + if (!card.getAttribute('aria-label')) { + const label = name ? (role ? `${name}, ${role}` : name) : 'View profile'; + card.setAttribute('aria-label', label); } - }); + card.addEventListener('keydown', (event) => { + if (event.key === 'Enter' || event.key === ' ') { + event.preventDefault(); + card.click(); + } + }); + } + card.addEventListener('click', () => { trigger = card; }, true); }); -// Into the dialog when it opens, back to the card when it closes, and Tab stays inside while open. +const closeOpenModal = (open) => { + if (!open) return; + open.classList.remove('active'); + document.body.style.overflow = ''; +}; + +// Into the dialog when it opens, back to the card when it closes, and Escape / Tab stay handled while open. +const focusDialog = (open) => { + const closeBtn = open.querySelector('.sc-close-btn'); + if (!closeBtn || open.contains(document.activeElement)) return; + closeBtn.focus(); + if (document.activeElement !== closeBtn) { + requestAnimationFrame(() => { + if (open.classList.contains('active') && !open.contains(document.activeElement)) closeBtn.focus(); + }); + } +}; + const observer = new MutationObserver(() => { const open = backdrops.find((backdrop) => backdrop.classList.contains('active')); if (open) { - // The dialog can't take focus until its fade-in has made it visible. - if (!open.contains(document.activeElement)) setTimeout(() => open.querySelector('.sc-close-btn')?.focus(), 60); + if (!trigger && document.activeElement?.closest?.('.sc-card')) { + trigger = document.activeElement.closest('.sc-card'); + } + focusDialog(open); } else if (trigger) { trigger.focus(); trigger = null; @@ -73,10 +107,17 @@ const observer = new MutationObserver(() => { backdrops.forEach((backdrop) => observer.observe(backdrop, { attributes: true, attributeFilter: ['class'] })); document.addEventListener('keydown', (event) => { - if (event.key !== 'Tab') return; const open = backdrops.find((backdrop) => backdrop.classList.contains('active')); if (!open) return; - const stops = [...open.querySelectorAll('a[href],button')].filter((el) => el.getClientRects().length); + if (event.key === 'Escape') { + event.preventDefault(); + closeOpenModal(open); + return; + } + if (event.key !== 'Tab') return; + const stops = [...open.querySelectorAll('a[href],button:not([disabled]),[tabindex]:not([tabindex="-1"])')] + .filter((el) => el.getClientRects().length); + if (!stops.length) return; const first = stops[0]; const last = stops[stops.length - 1]; if (!open.contains(document.activeElement)) { diff --git a/scripts/data_artifact.py b/scripts/data_artifact.py index 6c76d4b3357..35077aad34b 100644 --- a/scripts/data_artifact.py +++ b/scripts/data_artifact.py @@ -32,7 +32,7 @@ "static/partials", "static/newsletters", "content/contributor-analysis", "content/publications/citation_chart.webp", ) -EXCLUDED = {"data/partners.json", "data/publications.yaml"} +EXCLUDED = {"data/partners.json", "data/publications.yaml", "static/data/open_research_games.json"} def git(root, *args): diff --git a/scripts/generate_sc_profiles.py b/scripts/generate_sc_profiles.py index 8b783a059a9..b269a9f1433 100755 --- a/scripts/generate_sc_profiles.py +++ b/scripts/generate_sc_profiles.py @@ -107,38 +107,48 @@