diff --git a/includes/Hooks.php b/includes/Hooks.php index bbb3119e..d06737ae 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -171,13 +171,11 @@ class Hooks implements ]; // Load compact links if no mw-interlanguage-selector element is present in the page HTML. - // We use the same mechanism as Skin::getDefaultModules and check the HTML for the presence in the HTML, - // using the class as the heuristic. // Note if the element is rendered by the skin, its assumed that no collapsing is needed. // See T264824 for more information. - if ( !$override && $isCompactLinksEnabled && - strpos( $out->getHTML(), 'mw-interlanguage-selector' ) === false - ) { + // Note for Vector 2022, this skin is loaded as it tightly-coupled with ext.uls.interface + // A client side check avoids loading @wikimedia/codex for that skin. + if ( !$override && $isCompactLinksEnabled ) { $out->addModules( 'ext.uls.compactlinks' ); // Add styles for the default button in the page. $this->loadCodexStyles( $out ); diff --git a/resources/js/ext.uls.compactlinks.js b/resources/js/ext.uls.compactlinks.js index 4c4a9493..65fd2666 100644 --- a/resources/js/ext.uls.compactlinks.js +++ b/resources/js/ext.uls.compactlinks.js @@ -189,10 +189,13 @@ for ( language in this.compactList ) { this.compactList[ language ].parentNode.style.display = ''; } - - mw.loader.using( '@wikimedia/codex' ).then( function () { - this.addTrigger(); - }.bind( this ) ); + // If there is an interlanguage selector in the page already + // there is no need to add a trigger and Codex styles (T353850). + if ( !$( '.mw-interlanguage-selector' ).length ) { + mw.loader.using( '@wikimedia/codex' ).then( function () { + this.addTrigger(); + }.bind( this ) ); + } mw.hook( 'mw.uls.compactlinks.initialized' ).fire( true ); };