diff --git a/ui/widgets/menu.js b/ui/widgets/menu.js index 7706ee578..3b17112f8 100644 --- a/ui/widgets/menu.js +++ b/ui/widgets/menu.js @@ -626,7 +626,13 @@ return $.widget( "ui.menu", { } if ( this._hasScroll() ) { base = this.active.offset().top; - height = this.element.height(); + height = this.element.innerHeight(); + + // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back. + if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) { + height += this.element[ 0 ].offsetHeight - this.element.outerHeight(); + } + this.active.nextAll( ".ui-menu-item" ).each( function() { item = $( this ); return item.offset().top - base - height < 0; @@ -650,7 +656,13 @@ return $.widget( "ui.menu", { } if ( this._hasScroll() ) { base = this.active.offset().top; - height = this.element.height(); + height = this.element.innerHeight(); + + // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back. + if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) { + height += this.element[ 0 ].offsetHeight - this.element.outerHeight(); + } + this.active.prevAll( ".ui-menu-item" ).each( function() { item = $( this ); return item.offset().top - base + height > 0;