Revise logic for creating compact links button on Vector 2022

The existing strpos code is not working and the code is loading on
Vector 2022, it also appears to be required on Vector 2022 as without
it the language button does not appear to work (these should be
decoupled in a later patch)

The easiest possible solution here, is to move the check to the
client side and not create the trigger button in Vector 2022. e.g. do
the equivalent check for the node existence in the client instead
of the server side.

Bug: T353850
Change-Id: I44835e672bce97a7d3a98d9d75c4805ee2cc448d
This commit is contained in:
Jon Robson
2024-01-02 11:02:17 -08:00
committed by jenkins-bot
parent 3b545d5a23
commit 14e3be1cd3
2 changed files with 10 additions and 9 deletions

View File

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

View File

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