Skip to content

Commit cf1470d

Browse files
committed
Menu: Replace accidentally removed scroll-handling code in focus
1 parent a8d0e4c commit cf1470d

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

ui/jquery.ui.menu.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,21 @@ $.widget( "ui.menu", {
294294
focus: function( event, item ) {
295295
this.blur( event );
296296

297+
if ( this._hasScroll() ) {
298+
var borderTop = parseFloat( $.curCSS( this.activeMenu[0], "borderTopWidth", true ) ) || 0,
299+
paddingTop = parseFloat( $.curCSS( this.activeMenu[0], "paddingTop", true ) ) || 0,
300+
offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop,
301+
scroll = this.activeMenu.scrollTop(),
302+
elementHeight = this.activeMenu.height(),
303+
itemHeight = item.height();
304+
305+
if ( offset < 0 ) {
306+
this.activeMenu.scrollTop( scroll + offset );
307+
} else if ( offset + itemHeight > elementHeight ) {
308+
this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
309+
}
310+
}
311+
297312
this.active = item.first()
298313
.children( "a" )
299314
.addClass( "ui-state-focus" )

0 commit comments

Comments
 (0)