fix: prevent browser from scrolling to the tab before Tabber updates the aria attributes

Fixes: #161
This commit is contained in:
alistair3149 2024-07-03 17:49:19 -04:00
parent 14becfd4a6
commit 1e5ad6592b
No known key found for this signature in database

View file

@ -683,10 +683,11 @@ async function load( tabberEls ) {
setTimeout( () => {
// Delay animation execution so it doesn't not animate the tab gets into position on load
TabberAction.toggleAnimation( true );
window.addEventListener( 'hashchange', () => {
window.addEventListener( 'hashchange', ( event ) => {
const newHash = window.location.hash.slice( 1 );
const tab = document.getElementById( `tab-${ CSS.escape( newHash ) }` );
if ( tab ) {
event.preventDefault();
tab.click();
}
} );