fix: expose Related Stories card focus
This commit is contained in:
2 files changed
+46
No files matched your search
@@ -44,6 +44,10 @@ html[data-theme="light"] .chrnx-related-posts {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.chrnx-related-card:focus-within {
|
||||
box-shadow: inset 0 0 0 3px var(--chrnx-related-focus-ring);
|
||||
}
|
||||
|
||||
.chrnx-related-posts.is-layout-grid .chrnx-related-posts__items {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
|
||||
@@ -401,6 +401,48 @@ for ( const theme of [ 'light', 'dark' ] ) {
|
||||
}
|
||||
}
|
||||
|
||||
for ( const theme of [ 'light', 'dark' ] ) {
|
||||
test( `full-card keyboard focus remains visible inside clipped ${ theme } cards`, async ( {
|
||||
page,
|
||||
browserName,
|
||||
} ) => {
|
||||
await page.setViewportSize( { width: 1440, height: 900 } );
|
||||
await page.goto( '/long-title-night-writing-fixture/' );
|
||||
await page.evaluate( ( selectedTheme ) => {
|
||||
window.localStorage.setItem( 'chrnx-theme', selectedTheme );
|
||||
}, theme );
|
||||
await page.reload();
|
||||
|
||||
const links = page.locator( '#related-stories-5-grid .chrnx-related-card__link' );
|
||||
const focusedLink = links.nth( 1 );
|
||||
await links.first().focus();
|
||||
await page.keyboard.press( tabShortcut( browserName ) );
|
||||
await expect( focusedLink ).toBeFocused();
|
||||
|
||||
const appearance = await focusedLink.evaluate( ( link ) => {
|
||||
const card = link.closest( '.chrnx-related-card' );
|
||||
const cardStyle = window.getComputedStyle( card );
|
||||
const linkStyle = window.getComputedStyle( link );
|
||||
const colors = cardStyle.boxShadow.match(
|
||||
/rgba?\([^)]+\)|color\(srgb\s+[\d.]+\s+[\d.]+\s+[\d.]+(?:\s*\/\s*[\d.]+)?\)/gi,
|
||||
);
|
||||
return {
|
||||
background: cardStyle.backgroundColor,
|
||||
cardOverflow: cardStyle.overflow,
|
||||
cardShadow: cardStyle.boxShadow,
|
||||
linkShadow: linkStyle.boxShadow,
|
||||
ring: colors?.at( -1 ) || null,
|
||||
};
|
||||
} );
|
||||
|
||||
expect( appearance.cardOverflow ).toBe( 'hidden' );
|
||||
expect( appearance.linkShadow ).not.toBe( 'none' );
|
||||
expect( appearance.cardShadow ).toContain( 'inset' );
|
||||
expect( appearance.ring ).toBeTruthy();
|
||||
expect( contrast( appearance.ring, appearance.background ) ).toBeGreaterThanOrEqual( 3 );
|
||||
} );
|
||||
}
|
||||
|
||||
test( 'layout matrix rail hover stays visibly contained in its scrollport', async ( { page } ) => {
|
||||
await page.setViewportSize( { width: 900, height: 900 } );
|
||||
await page.goto( '/long-title-night-writing-fixture/' );
|
||||
|
||||
Reference in new issue
Block a user