Moves the logic that scrolls the rcfilters search input into view
from the onInputFocus callback to the onMenuToggle callback.
This allows the scroll behaviour to be triggered on mobile when
you tap the active filters area, and prevents the scroll behaviour
from triggering when the menu closes on mobile.
Bug: T229360
Change-Id: I1ca5c59e16a5dc6c6f473bbf3825a3e7c1e0f28e
* @param {boolean} isVisible Menu is visible
*/
FilterTagMultiselectWidget.prototype.onMenuToggle = function ( isVisible ) {
* @param {boolean} isVisible Menu is visible
*/
FilterTagMultiselectWidget.prototype.onMenuToggle = function ( isVisible ) {
+
+ var scrollToElement = this.isMobile ? this.input.$input : this.$element;
+
// Parent
FilterTagMultiselectWidget.parent.prototype.onMenuToggle.call( this );
// Parent
FilterTagMultiselectWidget.parent.prototype.onMenuToggle.call( this );
+
+ // Only scroll to top of the viewport if:
+ // - The widget is more than 20px from the top
+ // - The widget is not above the top of the viewport (do not scroll downwards)
+ // (This isn't represented because >20 is, anyways and always, bigger than 0)
+ this.scrollToTop( scrollToElement, 0, { min: 20, max: Infinity } );
+
} else {
// Clear selection
this.selectTag( null );
} else {
// Clear selection
this.selectTag( null );
* @inheritdoc
*/
FilterTagMultiselectWidget.prototype.onInputFocus = function () {
* @inheritdoc
*/
FilterTagMultiselectWidget.prototype.onInputFocus = function () {
- var scrollToElement = this.isMobile ? this.input.$input : this.$element;
// treat the input as a menu toggle rather than a text field on mobile
if ( this.isMobile ) {
// treat the input as a menu toggle rather than a text field on mobile
if ( this.isMobile ) {
// Parent
FilterTagMultiselectWidget.parent.prototype.onInputFocus.call( this );
}
// Parent
FilterTagMultiselectWidget.parent.prototype.onInputFocus.call( this );
}
-
- // Only scroll to top of the viewport if:
- // - The widget is more than 20px from the top
- // - The widget is not above the top of the viewport (do not scroll downwards)
- // (This isn't represented because >20 is, anyways and always, bigger than 0)
- this.scrollToTop( scrollToElement, 0, { min: 20, max: Infinity } );