fix: restore Related Stories resize focus
This commit is contained in:
5 files changed
+24
-37
No files matched your search
@@ -270,7 +270,7 @@ describe( 'Related Stories progressive controllers', () => {
|
||||
);
|
||||
|
||||
test.each( [ 'previous', 'next' ] )(
|
||||
'900 to 901 moves %s focus to heading before controls hide',
|
||||
'900 to 901 moves %s focus to the first card link before controls hide',
|
||||
( button ) => {
|
||||
const { initialize } = require( modulePath );
|
||||
const media = createMedia( true );
|
||||
@@ -281,6 +281,7 @@ describe( 'Related Stories progressive controllers', () => {
|
||||
fixture.track.dispatchEvent( new Event( 'scroll' ) );
|
||||
}
|
||||
fixture[ button ].focus();
|
||||
const firstLink = fixture.cards[ 0 ].querySelector( 'a' );
|
||||
|
||||
let focusAtHide = null;
|
||||
let hidden = fixture.controls.hidden;
|
||||
@@ -296,10 +297,8 @@ describe( 'Related Stories progressive controllers', () => {
|
||||
} );
|
||||
|
||||
media.change( false );
|
||||
expect( focusAtHide ).toBe( fixture.heading );
|
||||
expect( document.activeElement ).toBe( fixture.heading );
|
||||
expect( fixture.heading.getAttribute( 'tabindex' ) ).toBe( '-1' );
|
||||
document.querySelector( '[data-unrelated]' ).focus();
|
||||
expect( focusAtHide ).toBe( firstLink );
|
||||
expect( document.activeElement ).toBe( firstLink );
|
||||
expect( fixture.heading.hasAttribute( 'tabindex' ) ).toBe( false );
|
||||
expect( fixture.controls.hidden ).toBe( true );
|
||||
},
|
||||
@@ -316,11 +315,9 @@ describe( 'Related Stories progressive controllers', () => {
|
||||
fixture.geometry.clientWidth = fixture.geometry.scrollWidth;
|
||||
window.dispatchEvent( new Event( 'resize' ) );
|
||||
|
||||
expect( document.activeElement ).toBe( fixture.heading );
|
||||
expect( document.activeElement ).toBe( fixture.cards[ 0 ].querySelector( 'a' ) );
|
||||
expect( fixture.controls.hidden ).toBe( true );
|
||||
expect( fixture.next.disabled ).toBe( false );
|
||||
expect( fixture.heading.getAttribute( 'tabindex' ) ).toBe( '-1' );
|
||||
document.querySelector( '[data-unrelated]' ).focus();
|
||||
expect( fixture.heading.hasAttribute( 'tabindex' ) ).toBe( false );
|
||||
} );
|
||||
|
||||
|
||||
Reference in new issue
Block a user