Skip to content
Permalink
Browse files

Autocomplete: Added check to prevent accidental focus of menu-item on…

… page load in Firefox. Fixed #7024 - Autocomplete menu options are activated even if mouse is not moved.
  • Loading branch information...
kborchers authored and scottgonzalez committed May 18, 2012
1 parent 0adc6f5 commit 098dd1404b7b6025a5735495a91ca2b964c5cb3e
Showing with 16 additions and 0 deletions.
  1. +16 −0 ui/jquery.ui.autocomplete.js
@@ -57,6 +57,7 @@ $.widget( "ui.autocomplete", {

this.isMultiLine = this.element.is( "textarea,[contenteditable]" );
this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
this.isNewMenu = true;

this.element
.addClass( "ui-autocomplete-input" )
@@ -220,6 +221,20 @@ $.widget( "ui.autocomplete", {
}
},
menufocus: function( event, ui ) {
// #7024 - Prevent accidental activation of menu items in Firefox
if ( this.isNewMenu ) {
this.isNewMenu = false;
if ( event.originalEvent && /^mouse/.test(event.originalEvent.type) ) {
this.menu.blur();

this.document.one( "mousemove", function() {
$( event.target ).trigger( event.originalEvent );
});

return;
}
}

// back compat for _renderItem using item.autocomplete, via #7810
// TODO remove the fallback, see #8156
var item = ui.item.data( "ui-autocomplete-item" ) || ui.item.data( "item.autocomplete" );
@@ -422,6 +437,7 @@ $.widget( "ui.autocomplete", {
if ( this.menu.element.is(":visible") ) {
this.menu.element.hide();
this.menu.blur();
this.isNewMenu = true;
this._trigger( "close", event );
}
},

0 comments on commit 098dd14

Please sign in to comment.
You can’t perform that action at this time.