Focus problem when Ajax call for multiple fields calling the same callback function
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