diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js index 9b20f41fbb..875bddccd5 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterSelectWidget.js @@ -15,6 +15,7 @@ * @param {Object} config * @cfg {ve.ui.MWTransclusionOutlineParameterWidget[]} items * @property {string|null} activeParameter Name of the currently selected parameter + * @property {number|null} stickyHeaderHeight */ ve.ui.MWTransclusionOutlineParameterSelectWidget = function VeUiMWTransclusionOutlineParameterSelectWidget( config ) { // Parent constructor @@ -36,6 +37,7 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget = function VeUiMWTransclusionOu } ); this.activeParameter = null; + this.stickyHeaderHeight = null; }; /* Inheritance */ @@ -127,8 +129,8 @@ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.setActiveParameter = * @inheritDoc OO.ui.SelectWidget */ ve.ui.MWTransclusionOutlineParameterSelectWidget.prototype.highlightItem = function ( item ) { - if ( item ) { - item.scrollToView(); + if ( item && this.stickyHeaderHeight ) { + item.ensureVisibilityBelowStickyHeader( this.stickyHeaderHeight ); } ve.ui.MWTransclusionOutlineParameterSelectWidget.super.prototype.highlightItem.call( this, item ); }; diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.js index 5e29b340a8..a0c694ec72 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineParameterWidget.js @@ -87,9 +87,10 @@ ve.ui.MWTransclusionOutlineParameterWidget.prototype.toggleHasValue = function ( /** * Custom method to scroll parameter into view respecting the sticky part that sits above + * + * @param {number} stickyHeaderHeight */ -ve.ui.MWTransclusionOutlineParameterWidget.prototype.scrollToView = function () { +ve.ui.MWTransclusionOutlineParameterWidget.prototype.ensureVisibilityBelowStickyHeader = function ( stickyHeaderHeight ) { // make sure parameter is visible and scrolled underneath the sticky - // TODO find a dynamic way to get height of the sticky part - this.scrollElementIntoView( { animate: false, padding: { top: 114 } } ); + this.scrollElementIntoView( { animate: false, padding: { top: stickyHeaderHeight } } ); }; diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js index 345b916075..b3866db568 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWTransclusionOutlineTemplateWidget.js @@ -350,6 +350,10 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.toggleFilters = function () } else if ( visible ) { this.initializeFilters(); this.updateUnusedParameterToggleState(); + if ( this.parameterList ) { + // TODO find a dynamic way to get height of the sticky part + this.parameterList.stickyHeaderHeight = 114; + } } }; @@ -464,7 +468,8 @@ ve.ui.MWTransclusionOutlineTemplateWidget.prototype.scrollTopIntoView = function if ( this.parameterList ) { var firstSelected = this.parameterList.findFirstSelectedItem(); if ( firstSelected ) { - firstSelected.scrollToView(); + // FIXME: This code should be in {@see ve.ui.MWTransclusionOutlineParameterSelectWidget} + firstSelected.ensureVisibilityBelowStickyHeader( this.parameterList.stickyHeaderHeight ); } } };