From 1f6a2863218961900f56451cdb011366e9eecd3a Mon Sep 17 00:00:00 2001 From: Max Edell Date: Wed, 18 Oct 2023 17:20:09 -0700 Subject: [PATCH] fix: a11y workaround for splide --- blocks/card-carousel/card-carousel.js | 38 ++++++++++++++------------- blocks/resources/resources.js | 25 +++++++++--------- 2 files changed, 33 insertions(+), 30 deletions(-) diff --git a/blocks/card-carousel/card-carousel.js b/blocks/card-carousel/card-carousel.js index e38cc7a..34c582f 100644 --- a/blocks/card-carousel/card-carousel.js +++ b/blocks/card-carousel/card-carousel.js @@ -2,25 +2,26 @@ import { loadCSS } from '../../scripts/lib-franklin.js'; const TAG_NAME = 'card-carousel'; const BUNDLE_PATH = (ext) => `${window.hlx.codeBasePath}/blocks/card-carousel/splide.min.${ext}`; -const TEMPLATE = /* html */ ` +// NOTE: using divs instead of lists due to an a11y bug in splide +// see: https://github.com/radix-ui/primitives/issues/1703 +const TEMPLATE = /* html */ `\ -`; +
+
+`; const SPLIDE_CONFIG = { arrowPath: @@ -97,6 +98,7 @@ export class CardCarousel extends HTMLElement { if (loaded && splideRoot) { const splide = new window.Splide(splideRoot, SPLIDE_CONFIG); splide.mount(); + // Wait a tick and then trigger a refresh on the size setTimeout(() => { splide.refresh(); diff --git a/blocks/resources/resources.js b/blocks/resources/resources.js index cb4057a..7724986 100644 --- a/blocks/resources/resources.js +++ b/blocks/resources/resources.js @@ -44,20 +44,21 @@ async function renderXMLAsCards(url) { year: 'numeric', }); - cards += ` -
  • - + - ${readTime[0].textContent} min. read -
    - - ${title[0].textContent} - ${pubDate && `${pubDateToLocale}`} -
    -
    -
  • - `; + ${readTime[0].textContent} min. read +
    + + ${title[0].textContent} + ${pubDate && `${pubDateToLocale}`} +
    + + `; } const carouselList = document.querySelector(