mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-12 01:09:20 +00:00
Move code for adding sticky header class to SkinVector22.php
Per the comment at the top of the file, much more of this code needs to be moved to SkinVector22.php, but this is causing a specific regression, so can be moved now. Bug: T312782 Change-Id: Ief7581782f1e4eefc7474cceb81830783dff99a8
This commit is contained in:
parent
88b7d9534a
commit
e2d70c383e
|
@ -117,7 +117,6 @@ abstract class SkinVector extends SkinMustache {
|
|||
];
|
||||
private const SEARCH_SHOW_THUMBNAIL_CLASS = 'vector-search-box-show-thumbnail';
|
||||
private const SEARCH_AUTO_EXPAND_WIDTH_CLASS = 'vector-search-box-auto-expand-width';
|
||||
private const STICKY_HEADER_ENABLED_CLASS = 'vector-sticky-header-enabled';
|
||||
private const CLASS_QUIET_BUTTON = 'mw-ui-button mw-ui-quiet';
|
||||
private const CLASS_PROGRESSIVE = 'mw-ui-progressive';
|
||||
private const CLASS_ICON_BUTTON = 'mw-ui-icon mw-ui-icon-element';
|
||||
|
@ -370,30 +369,6 @@ abstract class SkinVector extends SkinMustache {
|
|||
Hooks::onSkinTemplateNavigation( $skin, $content_navigation );
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getHtmlElementAttributes() {
|
||||
$original = parent::getHtmlElementAttributes();
|
||||
|
||||
if ( VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_STICKY_HEADER ) ) {
|
||||
// T290518: Add scroll padding to root element when the sticky header is
|
||||
// enabled. This class needs to be server rendered instead of added from
|
||||
// JS in order to correctly handle situations where the sticky header
|
||||
// isn't visible yet but we still need scroll padding applied (e.g. when
|
||||
// the user navigates to a page with a hash fragment in the URI). For this
|
||||
// reason, we can't rely on the `vector-sticky-header-visible` class as it
|
||||
// is added too late.
|
||||
//
|
||||
// Please note that this class applies scroll padding which does not work
|
||||
// when applied to the body tag in Chrome, Safari, and Firefox (and
|
||||
// possibly others). It must instead be applied to the html tag.
|
||||
$original['class'] = implode( ' ', [ $original['class'] ?? '', self::STICKY_HEADER_ENABLED_CLASS ] );
|
||||
}
|
||||
|
||||
return $original;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate data needed to generate the sticky header.
|
||||
* @param array $searchBoxData
|
||||
|
|
|
@ -11,6 +11,7 @@ use MediaWiki\MediaWikiServices;
|
|||
*/
|
||||
class SkinVector22 extends SkinVector {
|
||||
private const TOC_AB_TEST_NAME = 'skin-vector-toc-experiment';
|
||||
private const STICKY_HEADER_ENABLED_CLASS = 'vector-sticky-header-enabled';
|
||||
|
||||
/**
|
||||
* Updates the constructor to conditionally disable table of contents in article
|
||||
|
@ -137,6 +138,30 @@ class SkinVector22 extends SkinVector {
|
|||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function getHtmlElementAttributes() {
|
||||
$original = parent::getHtmlElementAttributes();
|
||||
|
||||
if ( VectorServices::getFeatureManager()->isFeatureEnabled( Constants::FEATURE_STICKY_HEADER ) ) {
|
||||
// T290518: Add scroll padding to root element when the sticky header is
|
||||
// enabled. This class needs to be server rendered instead of added from
|
||||
// JS in order to correctly handle situations where the sticky header
|
||||
// isn't visible yet but we still need scroll padding applied (e.g. when
|
||||
// the user navigates to a page with a hash fragment in the URI). For this
|
||||
// reason, we can't rely on the `vector-sticky-header-visible` class as it
|
||||
// is added too late.
|
||||
//
|
||||
// Please note that this class applies scroll padding which does not work
|
||||
// when applied to the body tag in Chrome, Safari, and Firefox (and
|
||||
// possibly others). It must instead be applied to the html tag.
|
||||
$original['class'] = implode( ' ', [ $original['class'] ?? '', self::STICKY_HEADER_ENABLED_CLASS ] );
|
||||
}
|
||||
|
||||
return $original;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue