Skip to main content

Search and Top Navigation

#6635 closed bug (notabug)

Opened November 08, 2010 01:51PM UTC

Closed November 08, 2010 02:29PM UTC

Last modified October 11, 2012 09:15PM UTC

focus is broken after selecting

Reported by: shigella Owned by:
Priority: minor Milestone:
Component: ui.autocomplete Version: 1.8.6
Keywords: focus Cc:
Blocked by: Blocking:
Description

when bind a focus on a textfield and then after selecting an item the focus of the textfield is broken..

only after blur (clicking on a blank area of the form) you are able to focus again

Attachments (0)
Change History (8)

Changed November 08, 2010 02:02PM UTC by scottgonzalez comment:1

resolution: → worksforme
status: newclosed

I'm not sure what you mean, the text field instantly regains focus after selecting an item from the menu.

Changed November 08, 2010 02:25PM UTC by shigella comment:2

resolution: worksforme
status: closedreopened

i mean when selecting an item and you want to do a search again the text in the textfield remains in place

so if you first do this:

$j('#field').focus(function(){

$j(this).val('');

});

$j('#investigator').autocomplete({

minLength: 2,

source: function(request, response) {...},

select: function(event, ui) {

//at this moment you choose an item. if you do search immediately again the focus is broken and your selected text is not removed from the textfield. the following does not fix the problem

$j('#field).bind('focus');

}

});

Changed November 08, 2010 02:29PM UTC by scottgonzalez comment:3

resolution: → invalid
status: reopenedclosed

I'm not sure why you would bind to focus again inside the select event. Anyway, you can prevent the selection and clear the field. The plugin is working properly. If you need help with your specific use case, please use the forums.

Changed November 08, 2010 02:42PM UTC by shigella comment:4

it's for sure a bug..i don't think you understand the problem


"I'm not sure why you would bind to focus again inside the select event."

Because for some reason the focus which set earlier is broken after the select event

"Anyway, you can prevent the selection and clear the field. "

This is posibble with the focus: function(event, ui) { ... } set to false. But that's not the issue

After selecting an item the item text is set into the textfield. Focus (with the mouse) immediately in the textfield and do a search again is not possible because the text will remain in the textfield. The only way to do a search is to select the text and del or backspace it. But as i mentioned earlier: this must be done with the earlier :

$j('#field').focus(function(){

$j(this).val(' ');

});

But thats broken by the autocomplete select event

Changed November 08, 2010 02:53PM UTC by scottgonzalez comment:5

The original focus event handler is not broken at all after the select event. Returning false in the focus event has nothing to do with preventing the selection from the menu.

This is exactly what I'm talking about: http://jsbin.com/isate/edit

Changed November 08, 2010 06:49PM UTC by shigella comment:6

please try:

http://jsbin.com/idufa3/edit

select an item and go directly to the input field with your mouse to do a search again without clicking on the blank document(blur).

Result: the focus is broken

(i removed the "$( this ).val( "" );" from the select event, because the selected item (text) must be visible in the input field

Changed November 08, 2010 08:52PM UTC by scottgonzalez comment:7

There's nothing broken about that. The text field already has focus, so clicking it again does nothing. Please stop commenting on this ticket.

Changed October 11, 2012 09:15PM UTC by scottgonzalez comment:8

milestone: TBD

Milestone TBD deleted