devbridge / jQuery-Autocomplete

Ajax Autocomplete for jQuery allows you to easily create autocomplete/autosuggest boxes for text input fields
https://www.devbridge.com/sourcery/components/jquery-autocomplete/
Other
3.57k stars 1.67k forks source link

The input field doesn't receive focus when using .focus() #810

Closed tomdutton19 closed 3 years ago

tomdutton19 commented 3 years ago

Firstly, thanks so much for creating this - it's truly awesome.

I have a use case where we are detecting whether the user has selected a list value vs. free text input and if it's not from the list it triggers a challenge model form to get the user to answer a few more questions.

We are using a combination of:

onInvalidateSelection: function () { $('#inst_locale').val(""); $('#inst_id').val(""); unset_institution_image(); }

and

.blur(function() { setTimeout(institution_challenge, 300); // institution_challenge function calls the modal });

This works really well, and the modal is loading on blur, however I am a stuck trying to return the focus back to the autocomplete after they have exited the bootstrap modal.

We have a listener for when the user exits the modal.

$('.inst-challenge-revert').click(function(){ $('#autocomplete-id').focus(); });

However after the modal button is clicked, it seems to disable the autocomplete input completely and you can't even click in the input as if it is exhibiting disabled behaviour. Any help greatly appreciated.

Thanks

tkirda commented 3 years ago

The plugin has no code that would disable the input field. I suspect there might be side effects from other code included on the page.