fix: jumping to a tabber when no hash specified (#63)

Sorry for this oversight on my end.
This commit is contained in:
alex4401 2022-09-29 08:13:56 +02:00 committed by GitHub
parent f9983fb7a0
commit 787fede532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 );