diff --git a/docs/superpowers/specs/2026-08-12-related-stories-layouts-design.md b/docs/superpowers/specs/2026-08-12-related-stories-layouts-design.md index 89a3ba6..9b49c97 100644 --- a/docs/superpowers/specs/2026-08-12-related-stories-layouts-design.md +++ b/docs/superpowers/specs/2026-08-12-related-stories-layouts-design.md @@ -31,7 +31,7 @@ The block editor adds an inspector panel named “Related stories settings” wi `SelectControl` returns strings. Its `limit` handler strictly allowlists the incoming value and persists an integer: `setAttributes({ limit: Number(value) === 5 ? 5 : 3 })`. Tests prove the saved attribute is numeric `5`, never string `"5"`. -The block metadata declares `editorScript: file:../../assets/js/editor-related-posts.js`. Its adjacent asset metadata declares the WordPress dependencies used by a narrowly scoped `editor.BlockEdit` wrapper. This makes the controls available both in the post editor and in the Site Editor, where the Single template owns the default block instance; it does not rely on the post-only enqueue guard in `inc/editor.php`. +The block metadata declares `editorScript: file:../../assets/js/editor-related-posts.js`. Its adjacent asset metadata declares the WordPress block, block-editor, components, element, i18n, and server-side-render dependencies. The script calls `wp.blocks.registerBlockType( 'chrnx/related-posts', settings )` with the exact server attribute schema, a dynamic `edit` implementation, and `save: () => null`. The edit component renders `wp.serverSideRender` plus `InspectorControls`; it does not duplicate the PHP card query in JavaScript. This makes the block recognized, selectable, configurable, and serializable in both the post editor and Site Editor, where the Single template owns the default instance. It does not rely on the post-only enqueue guard in `inc/editor.php`. The server renderer owns validation. Malformed or legacy attributes fail closed to the defaults. Editor controls cannot be the only validation boundary. @@ -80,7 +80,7 @@ The renderer emits exactly one allowlisted class: `is-layout-adaptive`, `is-layo - Cards stay in a horizontal rail at every width. - Above 900px, each card is `(track width - 2 × computed gap) / 3`, within two CSS pixels, so three cards are visible. -- At 900px and below, each card occupies 82% of the track width, capped at 20rem. When another card exists, at least 24 CSS pixels and no more than 25% of it remain visible as a continuation cue. +- At 900px and below, each card has `flex-basis: calc(100% - clamp(3rem, 12vw, 7rem))` with no fixed maximum. After subtracting the computed track gap, the next card's visible continuation is at least 24 CSS pixels at every required test width and no more than 25% of that next card. One-card rails may use the full track width because no continuation cue is needed. - The rail uses `overflow-x: auto`, `scroll-snap-type: x mandatory`, and source-order cards with `scroll-snap-align: start`. - The page itself never gains horizontal overflow. @@ -96,7 +96,7 @@ A dedicated `assets/js/related-posts.js` controller enhances every rendered caro - The script does not autoplay, loop, clone cards, modify card links, export globals, or make network requests. - Missing markup, zero cards, unsupported browser APIs, or a reduced-motion preference fail safely. Reduced motion changes programmatic scrolling from smooth to instant without changing layout or content. - Controls carry the native `hidden` attribute in server output. Each controller removes it only after its track, cards, buttons, media query, and scroll APIs initialize successfully. With JavaScript disabled or controller initialization rejected, controls stay hidden and native scrolling remains available. -- If a viewport change turns an adaptive rail into a grid, the controller hides controls, removes the track's region/tab-stop enhancement, and leaves focus on a visible control before hiding when necessary. Crossing back restores rail semantics and control state. +- If a viewport change turns an adaptive rail into a grid while either navigation button owns focus, the controller first gives the always-visible section heading a temporary `tabindex="-1"`, focuses it with `preventScroll`, removes the temporary attribute, and only then hides the controls and removes the track's region/tab-stop enhancement. If focus is elsewhere, it stays unchanged. Crossing back restores rail semantics and control state. ## Accessibility @@ -120,6 +120,7 @@ This feature does not create production content, alter public permalink settings Test-driven implementation begins with failing tests for: - Exact block attribute enums/defaults and editor script registration. +- Client registration under WordPress 6.9.6: `getBlockType()` is non-null; the block is selectable in post and Site editors; inspector changes persist numeric `limit` and allowlisted `layout`; serialized dynamic markup contains the configured comment attributes and no saved HTML. - Server-side sanitization of malformed `limit` and `layout` attributes. - Exact item count for three, five, and fewer-than-requested results. - Layout classes and conditional control markup. @@ -129,7 +130,8 @@ Test-driven implementation begins with failing tests for: - CSS contracts for adaptive, grid, carousel, scroll snap, 45px controls, no-JS, reduced motion, and absence of page overflow. - Playwright coverage at 375, 768, 900, 901, 1440, and 2560 pixels in light and dark themes. - The complete `3/5 × adaptive/grid/carousel` matrix, plus adaptive availability counts of one, two, and four. -- Runtime geometry: exact grid column counts; carousel card width tolerances above; continuation preview bounds; correct control visibility at 900/901; track-only overflow; and `document.documentElement.scrollWidth <= document.documentElement.clientWidth`. +- Runtime geometry: exact grid column counts; carousel card width formula within two CSS pixels; 24px-to-25% continuation preview bounds; correct control visibility at 900/901; track-only overflow; and `document.documentElement.scrollWidth <= document.documentElement.clientWidth`. +- Resize focus regression in both directions, including 900→901 while Previous owns focus and while Next owns focus; the visible section heading becomes the destination before controls hide. - Real pointer/button and keyboard interaction without a focus trap. - No-JS access to every related story. - Clicking a seeded related story returns HTTP 200 rather than 404.