test: verify Related Stories workflows
This commit is contained in:
8 files changed
+702
-110
No files matched your search
@@ -84,6 +84,7 @@
|
||||
tabIndex: rememberAttribute( track, 'tabindex' ),
|
||||
};
|
||||
let rail = carousel || environment.media.matches;
|
||||
let clearHeadingFocus = null;
|
||||
|
||||
const updateEdges = () => {
|
||||
const maximum = Math.max( 0, track.scrollWidth - track.clientWidth );
|
||||
@@ -118,7 +119,17 @@
|
||||
const previousTabIndex = rememberAttribute( heading, 'tabindex' );
|
||||
heading.setAttribute( 'tabindex', '-1' );
|
||||
focusWithoutScroll( heading );
|
||||
restoreAttribute( heading, 'tabindex', previousTabIndex );
|
||||
if ( environment.document.activeElement !== heading ) {
|
||||
restoreAttribute( heading, 'tabindex', previousTabIndex );
|
||||
return;
|
||||
}
|
||||
const restoreHeadingTabIndex = () => {
|
||||
heading.removeEventListener( 'blur', restoreHeadingTabIndex );
|
||||
restoreAttribute( heading, 'tabindex', previousTabIndex );
|
||||
clearHeadingFocus = null;
|
||||
};
|
||||
heading.addEventListener( 'blur', restoreHeadingTabIndex, { once: true } );
|
||||
clearHeadingFocus = restoreHeadingTabIndex;
|
||||
};
|
||||
const applyViewport = () => {
|
||||
const nextRail = carousel || environment.media.matches;
|
||||
@@ -142,7 +153,13 @@
|
||||
const onPrevious = () => scroll( -1 );
|
||||
const onNext = () => scroll( 1 );
|
||||
const onMediaChange = () => applyViewport();
|
||||
const onResize = () => updateEdges();
|
||||
const onResize = () => {
|
||||
if ( adaptive && rail !== environment.media.matches ) {
|
||||
applyViewport();
|
||||
return;
|
||||
}
|
||||
updateEdges();
|
||||
};
|
||||
|
||||
previous.addEventListener( 'click', onPrevious );
|
||||
next.addEventListener( 'click', onNext );
|
||||
@@ -161,6 +178,9 @@
|
||||
if ( adaptive ) {
|
||||
environment.media.removeEventListener( 'change', onMediaChange );
|
||||
}
|
||||
if ( clearHeadingFocus ) {
|
||||
clearHeadingFocus();
|
||||
}
|
||||
controls.hidden = original.controlsHidden;
|
||||
previous.disabled = original.previousDisabled;
|
||||
next.disabled = original.nextDisabled;
|
||||
|
||||
Reference in new issue
Block a user