From 787fede5320f022343b166f7449e64fc490eff9c Mon Sep 17 00:00:00 2001 From: alex4401 <33527044+alex4401@users.noreply.github.com> Date: Thu, 29 Sep 2022 08:13:56 +0200 Subject: [PATCH] fix: jumping to a tabber when no hash specified (#63) Sorry for this oversight on my end. --- modules/ext.tabberNeue.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/ext.tabberNeue.js b/modules/ext.tabberNeue.js index 4aa04c2..19f9b2a 100644 --- a/modules/ext.tabberNeue.js +++ b/modules/ext.tabberNeue.js @@ -349,18 +349,19 @@ function initTabber( tabber, count ) { * Retrieve target hash and trigger show panel * If no targetHash is invalid, use the first panel * - * @param {boolean} isInitialLoad + * @param {boolean} scrollIntoView */ - function switchTab( isInitialLoad ) { + function switchTab( scrollIntoView ) { var targetHash = new mw.Uri( location.href ).fragment; - // Switch to the first tab if no targetHash or no tab is detected + // Switch to the first tab if no targetHash or no tab is detected and do not scroll to it // TODO: Remove the polyfill with CSS.escape when we are dropping IE support if ( !targetHash || !tabList.querySelector( '#tab-' + targetHash.replace( /[^a-zA-Z0-9-_]/g, '\\$&' ) ) ) { targetHash = tabList.firstElementChild.getAttribute( 'id' ).substring( 4 ); + scrollIntoView = false; } - showPanel( targetHash, false, isInitialLoad ); + showPanel( targetHash, false, scrollIntoView ); } switchTab( true );