Ticket #6635 (closed bug: notabug)

Opened 3 years ago

Last modified 7 months ago

focus is broken after selecting

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

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

Change History

comment:1 Changed 3 years ago by scott.gonzalez

  • Status changed from new to closed
  • Resolution set to worksforme

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

comment:2 Changed 3 years ago by shigella

  • Status changed from closed to reopened
  • Resolution worksforme deleted

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');

}

});

comment:3 Changed 3 years ago by scott.gonzalez

  • Status changed from reopened to closed
  • Resolution set to invalid

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.

comment:4 Changed 3 years ago by shigella

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

comment:5 Changed 3 years ago by scott.gonzalez

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

comment:6 Changed 3 years ago by shigella

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

comment:7 Changed 3 years ago by scott.gonzalez

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

comment:8 Changed 7 months ago by scott.gonzalez

  • Milestone TBD deleted

Milestone TBD deleted

Note: See TracTickets for help on using tickets.