From 8fb87bf221e57a1705d2858114e633ab9e4e8430 Mon Sep 17 00:00:00 2001 From: Diego Resendez Date: Wed, 12 Aug 2026 23:20:13 -0500 Subject: [PATCH] fix: contain focused Related Stories cards --- blocks/related-posts/style.css | 10 ++++++++-- tests/e2e/related-stories.spec.mjs | 10 ++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/blocks/related-posts/style.css b/blocks/related-posts/style.css index 2f7d8a7..ac606af 100644 --- a/blocks/related-posts/style.css +++ b/blocks/related-posts/style.css @@ -123,9 +123,12 @@ html[data-theme="light"] .chrnx-related-posts { @media (hover: hover) { + .chrnx-related-posts.is-layout-carousel .chrnx-related-card:hover { + transform: none; + } + .chrnx-related-posts.is-layout-carousel .chrnx-related-card:hover:not(:focus-within) { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--chrnx-green) 62%, transparent); - transform: none; } } @@ -147,9 +150,12 @@ html[data-theme="light"] .chrnx-related-posts { @media (hover: hover) { + .chrnx-related-posts.is-layout-adaptive .chrnx-related-card:hover { + transform: none; + } + .chrnx-related-posts.is-layout-adaptive .chrnx-related-card:hover:not(:focus-within) { box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--chrnx-green) 62%, transparent); - transform: none; } } } diff --git a/tests/e2e/related-stories.spec.mjs b/tests/e2e/related-stories.spec.mjs index 217fe3c..3dff8ab 100644 --- a/tests/e2e/related-stories.spec.mjs +++ b/tests/e2e/related-stories.spec.mjs @@ -467,9 +467,13 @@ for ( const theme of [ 'light', 'dark' ] ) { await expect( link ).toBeFocused(); await link.hover(); await expect( link ).toBeFocused(); + await page.waitForTimeout( 220 ); const appearance = await link.evaluate( ( focusedLink ) => { const card = focusedLink.closest( '.chrnx-related-card' ); + const trackElement = card.parentElement; + const cardRect = card.getBoundingClientRect(); + const trackRect = trackElement.getBoundingClientRect(); const style = window.getComputedStyle( card ); const token = style.getPropertyValue( '--chrnx-related-focus-ring' ).trim(); const probe = document.createElement( 'span' ); @@ -485,9 +489,15 @@ for ( const theme of [ 'light', 'dark' ] ) { ring: colors?.at( -1 ) || null, shadow: style.boxShadow, token: normalizedToken, + transform: style.transform, + topDelta: cardRect.top - trackRect.top, + bottomDelta: trackRect.bottom - cardRect.bottom, }; } ); + expect( appearance.transform ).toBe( 'none' ); + expect( appearance.topDelta ).toBeGreaterThanOrEqual( -1 ); + expect( appearance.bottomDelta ).toBeGreaterThanOrEqual( -1 ); expect( appearance.shadow ).toContain( 'inset' ); expect( appearance.shadow ).toMatch( /0px 0px 0px 3px/ ); expect( appearance.ring ).toBeTruthy();