Making an Auto-Playing Carousel Actually Pauseable: A Vue Component's WCAG Overhaul
Auto-playing carousels are common on marketing sites, and most of them fail WCAG 2.2.2 by lacking a pause, stop, or hide mechanism. The explicit pause button—placed first in the tab order—covers all input methods, unlike hover or focus-based shortcuts that break for keyboard and touch users.
The 0.2.26 release of a Vue carousel turns autoplay into an accessibility problem instead of an animation parameter. The original auto-advancing carousel had zero pause controls, no aria-live, no aria-roledescription, and kept ticking even under prefers-reduced-motion. Measuring with a 1-second interval and 14 assertions revealed that the first Tab stop landed on the previous arrow, focus didn't stop the timer, and screen readers got no announcement when slides changed.
The fix adds a real pause button placed before the arrows in DOM order, so the first Tab lands on it. The button is visually hidden with opacity:0 until hover, keyboard focus, or paused state, and uses aria-pressed. aria-live switches between off during autoplay and polite when paused, so screen readers aren't interrupted every three seconds. The carousel region gets role="region", aria-roledescription="carousel", and aria-label, and indicators get aria-current.
prefers-reduced-motion is read via matchMedia on mount, defaulting to paused, and visibilitychange clears the timer when the tab is hidden. The result: 14/14 real-device assertions pass, unit tests grew from 923 to 926, and the updated demo shows a working pause button.
Treating autoplay as an accessibility problem rather than a visual parameter shifts the design goal: pausing must be explicit and reachable, not inferred from hover or focus.
Focus-based auto-pause has a fundamental deadlock: the control itself retains focus after activation, so any focus-driven pause logic immediately stops the resumed playback. An explicit state variable decouples intent from focus position.
aria-live is not additive; turning it on permanently makes screen reader output worse. The correct pattern is to silence it during automatic updates and enable it only for user-triggered changes.
prefers-reduced-motion is a CSS media query; it does not stop JavaScript timers. Developers who assume it handles autoplay will see the timer keep running, so a separate matchMedia check is required.