Skip to content

Commit 14b3b60

Browse files
committed
Autocomplete: Style updates
Ref #14246
1 parent b2bf10e commit 14b3b60

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ui/widgets/autocomplete.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ $.widget( "ui.autocomplete", {
6565
pending: 0,
6666

6767
_create: function() {
68+
6869
// Some browsers only repeat keydown events, not keypress events,
6970
// so we use the suppressKeyPress flag to determine if we've already
7071
// handled the keydown event. #7269
@@ -120,8 +121,10 @@ $.widget( "ui.autocomplete", {
120121
this._keyEvent( "next", event );
121122
break;
122123
case keyCode.ENTER:
124+
123125
// when menu is open and has focus
124126
if ( this.menu.active ) {
127+
125128
// #6055 - Opera still allows the keypress to occur
126129
// which causes forms to submit
127130
suppressKeyPress = true;
@@ -140,6 +143,7 @@ $.widget( "ui.autocomplete", {
140143
this._value( this.term );
141144
}
142145
this.close( event );
146+
143147
// Different browsers have different default behavior for escape
144148
// Single press can mean undo or clear
145149
// Double press in IE means clear the whole form
@@ -148,6 +152,7 @@ $.widget( "ui.autocomplete", {
148152
break;
149153
default:
150154
suppressKeyPressRepeat = true;
155+
151156
// search timeout should be triggered before the input value is changed
152157
this._searchTimeout( event );
153158
break;
@@ -210,6 +215,7 @@ $.widget( "ui.autocomplete", {
210215
this.menu = $( "<ul>" )
211216
.appendTo( this._appendTo() )
212217
.menu( {
218+
213219
// disable ARIA support, the live region takes care of that
214220
role: null
215221
} )
@@ -219,6 +225,7 @@ $.widget( "ui.autocomplete", {
219225
this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
220226
this._on( this.menu.element, {
221227
mousedown: function( event ) {
228+
222229
// prevent moving focus out of the text field
223230
event.preventDefault();
224231

@@ -259,6 +266,7 @@ $.widget( "ui.autocomplete", {
259266
},
260267
menufocus: function( event, ui ) {
261268
var label, item;
269+
262270
// support: Firefox
263271
// Prevent accidental activation of menu items in Firefox (#7024 #9118)
264272
if ( this.isNewMenu ) {
@@ -276,6 +284,7 @@ $.widget( "ui.autocomplete", {
276284

277285
item = ui.item.data( "ui-autocomplete-item" );
278286
if ( false !== this._trigger( "focus", event, { item: item } ) ) {
287+
279288
// use value to match what will end up in the input, if it was a key event
280289
if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
281290
this._value( item.value );
@@ -297,6 +306,7 @@ $.widget( "ui.autocomplete", {
297306
if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
298307
this.element.trigger( "focus" );
299308
this.previous = previous;
309+
300310
// #6109 - IE triggers two focus events and the second
301311
// is asynchronous, so we need to reset the previous
302312
// term synchronously and asynchronously :-(
@@ -309,6 +319,7 @@ $.widget( "ui.autocomplete", {
309319
if ( false !== this._trigger( "select", event, { item: item } ) ) {
310320
this._value( item.value );
311321
}
322+
312323
// reset the term after the select event
313324
// this allows custom select handling to work properly
314325
this.term = this._value();
@@ -473,6 +484,7 @@ $.widget( "ui.autocomplete", {
473484
this._suggest( content );
474485
this._trigger( "open" );
475486
} else {
487+
476488
// use ._close() instead of .close() so we don't cancel future searches
477489
this._close();
478490
}
@@ -499,6 +511,7 @@ $.widget( "ui.autocomplete", {
499511
},
500512

501513
_normalize: function( items ) {
514+
502515
// assume all items have the right format when the first item is complete
503516
if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
504517
return items;
@@ -538,6 +551,7 @@ $.widget( "ui.autocomplete", {
538551
_resizeMenu: function() {
539552
var ul = this.menu.element;
540553
ul.outerWidth( Math.max(
554+
541555
// Firefox wraps long text (possibly a rounding bug)
542556
// so we add 1px to avoid the wrapping (#7513)
543557
ul.width( "" ).outerWidth() + 1,

0 commit comments

Comments
 (0)