Focus problem when Ajax call for multiple fields calling the same callback function I have implemented a custom form. I put same Ajax callback function for multiple field. When one Ajax call completes, I click on other field. But I can't unfocused previous field. Sometimes the Ajax call runs for multiple field.

My code: 

$form['worklocation'] = array(
    '#title' =&gt; t('Work Location'),
    '#type' =&gt; 'textfield',

   '#autocomplete_route_name' =&gt; 'advance_search_autocomplete_callback.advancesearch_autocomplete_callback',
    '#autocomplete_route_parameters' =&gt; array('type' =&gt; 'worklocation'),
    '#ajax' =&gt; array(
      'callback' =&gt; [$this, 'friends_advance_search_results'],
    ),
    '#attributes' =&gt; array('class' =&gt; array('form-control')),

  );

  $form['school'] = array(
    '#title' =&gt; t('School'),
    '#type' =&gt; 'textfield',

    '#autocomplete_route_name' =&gt; 'advance_search_autocomplete_callback.advancesearch_autocomplete_callback',
    '#autocomplete_route_parameters' =&gt; array('type' =&gt; 'school'),
    '#ajax' =&gt; array(
      'callback' =&gt; [$this, 'friends_advance_search_results'],
    ),
    '#attributes' =&gt; array('class' =&gt; array('form-control')),

  );
  $form['college'] = array(
    '#title' =&gt; t('College / University'),
    '#type' =&gt; 'textfield',

   '#autocomplete_route_name' =&gt; 'advance_search_autocomplete_callback.advancesearch_autocomplete_callback',
    '#autocomplete_route_parameters' =&gt; array('type' =&gt; 'college'),
    '#ajax' =&gt; array(
      'callback' =&gt; [$this, 'friends_advance_search_results'],
    ),
    '#attributes' =&gt; array('class' =&gt; array('form-control')),

  );


Callbakck: 

function friends_advance_search_results(array &amp;$form, FormStateInterface $form_state) {

 $search_result = array(
                    '#theme' =&gt; 'friends_advanced_search_list',
                    '#friends' =&gt; $friends_list,
                    '#info' =&gt; array('display' =&gt; 'hide', 'friend_recommend' =&gt; 0, 'load_more' =&gt; $load_more, 'no_results' =&gt; 1,'search_action' =&gt; 1),

                    );

   $output = render($search_result);
   $id = '#advanced-friend-list';
   $response = new AjaxResponse();
   $response-&gt;addCommand(new ReplaceCommand($id, $output)); 

   return $response; 

}


Problem:
Enable disable-refocus when adding the ajax callback:

'#ajax' =&gt; [
  'callback' =&gt; [$this, 'friends_advance_search_results'],
  'disable-refocus' =&gt; TRUE,
],


See https://www.drupal.org/project/drupal/issues/2627788