Restore scrolling parameters into view with(out) sticky header

This is a partial revert of Ide45141. Now the scrolling always
happens (again), but properly considers the presence of the sticky
header. It was also not correctly initialized on construction time.

This is a candidate for a backport. The patch is intentionally as
small as possible because of this. Code cleanup will be done in a
later patch.

Bug: T312926
Change-Id: I06425b42566bfb2087846636055ee75e98a05029
This commit is contained in:
Thiemo Kreuz 2022-08-02 12:13:06 +02:00
parent c626f93a1f
commit 0b28414dff
2 changed files with 13 additions and 4 deletions

View file

@ -129,7 +129,7 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.setActiveParameter =
* @inheritDoc OO.ui.SelectWidget
*/
ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightItem = function ( item ) {
if ( item && this.stickyHeaderHeight ) {
if ( item ) {
item.ensureVisibilityBelowStickyHeader( this.stickyHeaderHeight );
}
ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.highlightItem.call( this, item );

View file

@ -31,8 +31,7 @@ ve.ui.MWTransclusionOutlineTemplateWidget = function VeUiMWTransclusionOutlineTe
remove: 'onParameterRemovedFromTemplateModel'
} );
this.toggleFilters();
var canFilter = !!this.toggleUnusedWidget,
var canFilter = this.shouldFiltersBeShown(),
initiallyHideUnused = canFilter && !replacesPlaceholder && !this.transclusionModel.isSingleTemplate();
var parameterNames = this.getRelevantTemplateParameters( initiallyHideUnused ? 'used' : 'all' );
@ -46,6 +45,7 @@ ve.ui.MWTransclusionOutlineTemplateWidget = function VeUiMWTransclusionOutlineTe
this.$element.append( this.$noParametersNote );
}
this.toggleFilters();
if ( initiallyHideUnused ) {
// This is only to update the label of the "Hide unused" button
this.toggleUnusedWidget.toggleUnusedParameters( false );
@ -340,10 +340,19 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.onParameterWidgetListChanged
/**
* @private
* @return {boolean}
*/
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function () {
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.shouldFiltersBeShown = function () {
var numParams = this.getRelevantTemplateParameters().length,
visible = numParams >= this.constructor.static.searchableParameterCount;
return visible;
};
/**
* @private
*/
ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function () {
var visible = this.shouldFiltersBeShown();
if ( this.searchWidget ) {
this.searchWidget.toggle( visible );
this.toggleUnusedWidget.toggle( visible );