Repository navigation
fix(ui): upgrade swiper to v12 and add a carousel pause control - #119
Merged
Merged
Conversation
…tring
The CSS scoping pass is not the last thing to touch a selector. Native CSS
nesting is flattened downstream of it, by the minifier, and flattening moves the
scope off the head of the string without moving it out of the selector — so the
head-anchored `isSelectorScoped` read correctly-confined CSS as a host-page leak
and failed the build.
Swiper 12 is what surfaced it (it dropped its LESS/SCSS sources for nested CSS),
in two families, fifteen selectors:
:is(<scoped>, <scoped>) .swiper-lazy-preloader
.swiper-pagination-disabled > :is(<scoped>)
The second is the one that settles the design: no test that looks at the head of
the string can accept it, because the scope legitimately lives in the SUBJECT.
So ask the question the pass has always been for — is the element this rule
PAINTS necessarily inside the widget? — for which the head of the string was
only ever a proxy. Walk left from the subject compound through ancestor steps
and look for a compound that pins itself to the scope.
It stays a fix rather than a hole because every branch of an `:is()` must be
scoped (one unscoped branch is a way out of the widget) and because only
descendant/child combinators are followed: a sibling combinator also happens to
confine the subject in everything we emit, but that argument leans on the scoped
part being a strict descendant of the scope root, which is too fine a
distinction to rest a host-page guarantee on. Nothing needs it, so it is
refused.
The emitted bytes are unchanged — the specificity of every flattened form still
matches the unscoped original, because `:where()` continues to contribute zero.
Closes #104
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
GHSA-hmx5-qpq5-p643 (prototype pollution, `>=6.5.1 <12.1.2`) was the repo's only CRITICAL, and patching it needed a major. `pnpm audit --prod` now reports 0 critical, so the baseline waiver naming this ticket is removed with it — the weekly `--strict` run fails on a waiver whose advisory has been fixed, which is how a stale one prunes itself. The fix upstream is a `noExtend` list on the param-merge helper, which is the code path our `<Swiper>` props flow through. The v12 migration is a version number and nothing else. Its breaking changes are LESS/SCSS sources dropped (we import the CSS), SVG navigation icons (we have no Navigation module) and tighter types; `swiper/react` and all three CSS entry points — `swiper/css`, `/a11y`, `/pagination` — are unchanged, so `src/styles/globals.css` needed no edit and the `.sy-carousel` pagination theming still matches v12's DOM. Not taken: v14, which exists and is also patched, but is a second major (browser-baseline raise) and is not what the ticket scoped. The eager payload gets slightly SMALLER: 481.8 → 479.3 KiB standalone, 483.3 → 480.7 KiB embed. Closes #104 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
WCAG 2.2.2 (Pause, Stop, Hide): anything that moves for more than five seconds needs a way to stop it. The carousel autoplayed at 4s with `disableOnInteraction: false` and offered none, so the only way to read a caption under it was to out-pace it. - A toggle button over the image, keyboard-operable, localized across all ten locales. The accessible name stays put and `aria-pressed` carries the state: a name that flipped between "Pause"/"Play" alongside `aria-pressed` would announce the state twice and disagree with itself doing it. Only the glyph swaps. - Under `prefers-reduced-motion: reduce`, autoplay never starts — the repo's first reduced-motion support — and the control does not render, because there is nothing to pause. The images stay reachable by swipe and by the pagination bullets: the whole carousel minus the motion nobody asked for. - Read through `useSyncExternalStore`, not a `matchMedia().matches` at render, because the preference CHANGES: turning it on mid-session should settle the carousel, not wait for an unrelated re-render. Pressing pause calls `autoplay.stop()`, not `pause()`. That is the difference between the two acceptance criteria: `stop()` clears `running`, and every one of Swiper's interaction handlers — touch, transition end, pagination click, tab visibility — early-returns on `!running`. So no later interaction can silently restart what the viewer stopped, structurally rather than by our watching for it. The declarative `autoplay` prop only decides whether autoplay starts AT INIT: Swiper's React wrapper merges changed params into the live instance but never starts or stops it (`updateSwiper`). Every later change is therefore applied in an effect, which compares against `running` so a repeat can't queue a second timer — `start()` has no re-entry guard of its own. Single-slide behaviour is untouched: still a static slide, no autoplay, no pagination, and now no pause control either. Closes #104 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- The pause control was missing `data-vaul-no-drag`. The carousel renders on the vaul sheet (EventDetails), where a tap carrying any micro-movement is read as a drag and the click is swallowed — so the one control this branch exists to add would have fired only intermittently on touch, which is exactly where a pause affordance earns its keep. The Button atom sets it on every button and ActionRow carries it by hand; this now does too, and a spec pins it, since losing it again would be invisible to every other gate. - `usePrefersReducedMotion` moves to `src/hooks/use-reduced-motion.ts` and is rebuilt on `react-responsive`'s `useMediaQuery` — the media-query mechanism `config/responsive.ts` already uses. That deletes a hand-rolled `useSyncExternalStore` + `matchMedia` subscription which, being a local copy, had also skipped the environment guarding the widget's other preference reader carries: a bare `window.matchMedia` in a `getSnapshot` runs DURING render, so a host without it would have taken the whole photo section to an error panel. The hook is a `() => boolean` environment read with no carousel knowledge, and the repo already keeps single-importer hooks in `src/hooks/`. - Its docstring records why it is not framer-motion's `useReducedMotion`, which is already a dependency: that one reads the preference once at mount. The remaining reduced-motion surfaces are framer-motion animations whose natural fix is one `<MotionConfig reducedMotion="user">`, and whoever lands it should decide about the disagreement rather than discover it. - `isSubjectConfined` drops two parallel arrays for a single right-to-left scan; the combinator/compound pairing was rebuilding order `sel.nodes` already had. - Two comment corrections, both claims I had not checked. `start()` does not queue a second timer (`run()` clears the previous one) — the guard prevents a restarted countdown, which is a smaller and truer reason. And refusing sibling combinators is NECESSARY, not fastidious: a bare `.sy-atlas` counts as a scope token, so crediting siblings would accept `:is(:where(.sy-atlas)) ~ .b`, and a sibling of the scope ROOT is an arbitrary host element. - The scope gate's failure message no longer asserts a leak outright. A refusal can also be a shape the check declines to credit — `swiper/css/navigation` would produce one the day someone adds arrows — and this branch already spent a day looking for a leak that a flattened-but-confined selector did not have. Closes #104 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
- `.claude/rules/components.md` described the scoping pass as "rewrites every emitted selector to `:where(.sy-atlas)`", which stopped being the enforced invariant this branch. What the gate checks is that the element a rule PAINTS is inside the widget; those coincided only until a dependency shipped nested CSS the minifier flattens after us. The rule now says so, names the fact that we are not the last stage to rewrite a selector, and warns that a red gate can mean "not confined" rather than "leaks" — otherwise the next contributor reads the stale model first and goes looking for a leak that isn't there, which is most of what #104 cost. - The accessibility section gains the two rules this branch had to discover: motion needs a stop control and must not start under `prefers-reduced-motion` (with the worked example's toggle-button semantics and where the hook lives), and a hand-rolled control on the drawer needs `data-vaul-no-drag` or it fires only intermittently on touch. - CLAUDE.md's hooks list gains `use-reduced-motion`. Closes #104 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
… root Found by adversarially probing the predicate rather than reasoning about it: `.sy-atlas ~ .foo` and `:where(.sy-atlas) + .b` were accepted as confined. They are not. They style a SIBLING of the widget root, which is an arbitrary element of the host page — exactly the leak this gate exists to stop. The cause is the head fast path: leading with the scope is not the same as confining the subject, and the regex only ever checked the former. This predates the branch — but the branch made it incoherent, adding an explicit refusal of sibling combinators in the subject walk, with a comment explaining why it is necessary, immediately beside a path that accepted them anyway. The two now agree: the fast path declines any selector carrying `~`/`+` and lets the walk decide. Nothing emits that shape, so nothing was leaking. What was at risk was a hand-written `.sy-atlas ~ .foo` in globals.css, which the transform passes through untouched (correctly — it leads with the scope) and the gate would then have waved through. Checked: globals.css has no such rule today. The over-broad `[~+]` test also catches `:nth-child(2n+1)`, which just sends a rare selector down the slow path; the spec pins that it still resolves to true. Spec additions cover the sibling shapes and the scope-shaped tokens that do not confine — `:has()`, `:not()`, `[class~=…]`, `:nth-child(… of …)`, empty `:is()`. Closes #104 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Deploying sahajatlas-design with
|
| Latest commit: |
dbaed9e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a6d26c22.sahajatlas-design.pages.dev |
| Branch Preview URL: | https://fix-swiper-carousel.sahajatlas-design.pages.dev |
Deploying sahajatlas with
|
| Latest commit: |
dbaed9e
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://ae842424.sahajatlas.pages.dev |
| Branch Preview URL: | https://fix-swiper-carousel.sahajatlas.pages.dev |
Ardnived
added a commit
that referenced
this pull request
Aug 7, 2026
One conflict, in README.md's CSP block, and it was load-bearing: this branch added `https://cdn.usefathom.com` to script-src plus a warning that CSP ignores every repeat of a directive name after the first, while #121 added the widget's own origin as a SECOND `script-src` line — the exact mistake the warning describes. Merged onto one line carrying all three sources, so a host pasting the block actually gets Turnstile and Fathom rather than silently losing them, and kept both explanations. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #104
Two things in one ticket because they share
ImageCarousel.tsx: a CRITICAL advisory that needed a major bump, and the WCAG 2.2.2 failure in the component that bump touches.1. swiper 11.2.1 → 12.2.0 — the critical advisory is cleared
GHSA-hmx5-qpq5-p643 (prototype pollution, vulnerable
>=6.5.1 <12.1.2) was the repo's only critical.pnpm audit --prodnow reports 0 critical (was 1); 64 advisories → 63. The waiver naming this ticket is removed fromscripts/audit-baseline.json— the weekly--strictrun fails on a waiver whose advisory has been fixed, so a stale one would have gone red.The v12 migration turned out to be a version number and nothing else. Its breaking changes are LESS/SCSS sources dropped (we import the CSS), SVG navigation icons (we register no Navigation module), and tighter types.
swiper/reactand all three CSS entry points (swiper/css,/a11y,/pagination) are unchanged, sosrc/styles/globals.cssneeded no edit and the.sy-carouselpagination theming still matches v12's DOM. The upstream fix is anoExtend = ['__proto__','constructor','prototype']filter on the param-merge helper our<Swiper>props flow through.Not taken: v14, which exists and is also patched, but is a second major (browser-baseline raise) and is not what the ticket scoped.
The eager payload got smaller: 481.8 → 479.2 KiB standalone, 483.3 → 480.7 KiB embed (budget 495). Worth knowing for #96, which is lowering that budget concurrently.
2. The carousel can be stopped
The carousel autoplayed at 4s with
disableOnInteraction: falseand offered no way to stop it, so the only way to read a caption under it was to out-pace it.aria-pressedcarries the state — a name flipping "Pause"/"Play" besidearia-pressedannounces the state twice and disagrees with itself doing it. Only the glyph swaps.prefers-reduced-motion: reduceautoplay never starts (the repo's first reduced-motion support) and the control does not render, because there is nothing to pause. Images stay reachable by swipe and by the bullets: the whole carousel minus the motion nobody asked for.autoplay.stop(), notpause()— that distinction is what satisfies "interacting must not silently restart it".stop()clearsrunning, and every one of swiper's interaction handlers (touch, transition end, pagination click, tab visibility) early-returns on!running. The guarantee is structural, not something we watch for.autoplayprop only decides whether autoplay starts at init — swiper's React wrapper merges changed params but never starts/stops (updateSwiper) — so later changes are applied in an effect that compares againstrunning.3. Not in the ticket: the v12 CSS broke the scope gate, and the gate had a hole
Swiper 12 ships native CSS nesting (the consequence of dropping its LESS/SCSS sources). The scoping pass correctly leaves a nested rule to its parent's prefix — and then the minifier, which runs after us, flattens the nesting and folds the scope into the middle or the subject of the selector:
15 selectors like this. All correctly confined; the head-anchored check called every one a host-page leak and failed
pnpm build. SoisSelectorScopednow asks the question the pass has always been for — is the element this rule paints inside the widget? — instead of the proxy it was using. Note the shape above: no test that looks at the head of the string can accept it, because the scope legitimately lives in the subject.Probing that predicate adversarially then found a real hole, which predates this branch:
.sy-atlas ~ .foowas accepted as confined. It is not — it styles a sibling of the widget root, an arbitrary host element. The head fast path only ever checked that the scope led the selector. Nothing emits that shape, so nothing was leaking; the risk was a hand-written rule inglobals.css, which the transform passes through untouched and the gate would then have waved through. Fixed, and the branch had made it incoherent anyway — it added an explicit refusal of sibling combinators in the subject walk, with a comment on why it was necessary, right beside a path that accepted them.✓ assert-css-scoped: 1133 rules across 4 injected stylesheets confined to .sy-atlas.Verification
Gates:
lint·typecheck·test:run(677) ·build(incl.assert-css-scoped) ·size·ladle:build·audit:check(also clean under--strict).Browser-verified in Ladle (Playwright, real
emulateMedia), because none of this is expressible in the node lane:aria-pressed=true, glyph swaps, 0 advances in 10s, focus retainedMeasured rather than assumed (per
.claude/rules/code-style.mdon inert Tailwind classes): the control computes to 32×32,rgba(0,0,0,.5), a 2pxring-focusring, andend-2→inset-inline-end: 8px(logical, so it mirrors under RTL).Review passes
/simplifycompleted — 8 findings applied, most valuably a missingdata-vaul-no-drag: the carousel renders on the vaul sheet, which reads a tap with any micro-movement as a drag and swallows the click, so the one control this PR exists to add would have fired only intermittently on touch. A spec pins it now, since losing it again is invisible to every other gate. That pass also movedusePrefersReducedMotiontosrc/hooks/use-reduced-motion.tsand rebuilt it onreact-responsive— the mechanismconfig/responsive.tsalready uses — replacing a hand-rolledmatchMediasubscription that, being a local copy, had skipped the environment guarding the widget's other preference reader carries./code-reviewand/security-reviewdid not complete — both subagents died on API errors during a platform instability window, and per the coordinator were not re-dispatched further. The security-relevant surface (the scoping predicate) was instead triaged inline and empirically: 28 adversarial selectors run against the real predicate, covering:not(),:has(),:nth-child(… of …), empty/unscoped:is()branches, case variants, attribute selectors, prefix collisions (.sy-atlas-thing), and both failure paths (the gate accepting a leak, andscopeSelectorwrongly skipping a prefix). That is what found the sibling hole above. All 28 now behave as intended and are pinned in the spec. A human reviewer may still want a fresh pass onscripts/postcss-scope-widget.mjs.Unsigned commits — the 1Password SSH agent had no identities loaded this session.