Skip to main content

Search and Top Navigation

#10434 closed bug (worksforme)

Opened July 28, 2014 01:04PM UTC

Closed July 28, 2014 01:31PM UTC

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.

Attachments (0)
Change History (5)

Changed July 28, 2014 01:12PM UTC by scottgonzalez comment:1

owner: → Montago
status: newpending

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

Changed July 28, 2014 01:24PM UTC by Montago comment:2

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;

}

}

},

Changed July 28, 2014 01:26PM UTC by Montago comment:3

Replying to [comment:1 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.

Changed July 28, 2014 01:28PM UTC by Montago comment:4

Replying to [comment:1 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

Changed July 28, 2014 01:31PM UTC by scottgonzalez comment:5

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.