aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichał Gołębiowski-Owczarek <m.goleb@gmail.com>2020-07-23 15:55:18 +0200
committerGitHub <noreply@github.com>2020-07-23 15:55:18 +0200
commit1712b9bbb2e214819508b00d8f318713e27cd949 (patch)
treef3e4701d4767f5036b60f628732c006b3a0856a8
parent5e2fc44c0cf50e9bcb4f11a23ea5782653ab7eba (diff)
downloadjquery-ui-1712b9bbb2e214819508b00d8f318713e27cd949.tar.gz
jquery-ui-1712b9bbb2e214819508b00d8f318713e27cd949.zip
Menu: Account for scrollbars in jQuery 3.2
jQuery >=3.2 doesn't include scrollbars in `.height()`, this commit switches it to `.innerHeight()` which does so in jQuery >=3.3. In jQuery 3.2 it doesn't either so include scrollbars in innerHeight, add it back. Using `.innerHeight()` instead of `.height()` should be fine as menu doesn't define padding styles. Closes gh-1929
-rw-r--r--ui/widgets/menu.js16
1 files changed, 14 insertions, 2 deletions
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;