Opened 5 years ago

Closed 5 years ago

#10434 closed bug (worksforme)

autoFocus should select first 'real' item when using Groups

Reported by: Montago Owned by: Montago
Priority: minor Milestone: none
Component: ui.autocomplete Version: 1.11.0
Keywords: Cc:
Blocked by: Blocking:

Description

I guess it should either be automatic or optional.

If its intended that the user should be able to select a group, then an option should enable it. Otherwise i think that the first autofocused element should be the first "Real" element

eg: if item_0 = Group => select item_1 if item_0 = Group and item_1 = Group (Group_0 = empty), then select item_2...

it makes no sense to select an element that can't be selected.

Change History (5)

comment:1 Changed 5 years ago by Scott González

Owner: set to Montago
Status: newpending

I'm not sure what you're referring to. Autocomplete has no concept of groups.

comment:2 Changed 5 years ago by Montago

Status: pendingnew

proposed fix:

_suggest: function( items ) {

var ul = this.menu.element.empty(); this._renderMenu( ul, items ); this.isNewMenu = true; this.menu.refresh();

size and position menu ul.show(); this._resizeMenu(); ul.position( $.extend({

of: this.element

}, this.options.position ) );

if (this.options.autoFocus) {

for (i = 0, S=null ; S=items[i] ; i++)

if (S.group) {

this.menu.next();

} else {

this.menu.next(); break;

}

}

},

comment:3 in reply to:  1 Changed 5 years ago by Montago

Replying to scott.gonzalez:

I'm not sure what you're referring to. Autocomplete has no concept of groups.

Ahh...

im working on someone elses code.. i assumed that autocomplete supported this feature out of the box.

comment:4 in reply to:  1 Changed 5 years ago by Montago

Replying to scott.gonzalez:

I'm not sure what you're referring to. Autocomplete has no concept of groups.

i guess im refering to this feature: http://jqueryui.com/autocomplete/#categories

comment:5 Changed 5 years ago by Scott González

Resolution: worksforme
Status: newclosed

This already works properly. Going to http://view.jqueryui.com/1.11.0/demos/autocomplete/categories.html and running $( "#search" ).catcomplete({ autoFocus: true }); in the console, then typing "h" in the input focusing the first actual item.

Note: See TracTickets for help on using tickets.