<commit_before>$( function() {
  if ( $('.edit-adopter').length > 0) {
    var remoteSource = function(request, response) {
      $.getJSON('/dogs?all_dogs=true&search=' + request.term, function(data) {
        var results = [];
        data.forEach( function(item) {
          results.push({label: item.name, value: item.id});
        });
        response(results);
      });
    };

    var itemSelected = function(e, ui) {
      $('#autocomplete_label').val(ui.item.label);
      $('#adoption_dog_id').val(ui.item.value);
      return false;
    };

    var focusEvent = function(event, ui) {
      $('#autocomplete_label').val(ui.item.label);
      return false;
    };

    var responseHandler = function(event, ui) {
      if (ui.content.length == 1) {
        ui.item = ui.content[0];
        $(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
        $(this).autocomplete('close');
      }
    };

    $('.autocomplete')
      .autocomplete({
        focus: focusEvent,
        minLength: 2,
        response: responseHandler,
        select: itemSelected,
        source: remoteSource
      });
  }
});<commit_msg>Blurs field so you can't keep typing after autoselect<commit_after>$( function() {
  if ( $('.edit-adopter').length > 0) {
    var remoteSource = function(request, response) {
      $.getJSON('/dogs?all_dogs=true&search=' + request.term, function(data) {
        var results = [];
        data.forEach( function(item) {
          results.push({label: item.name, value: item.id});
        });
        response(results);
      });
    };

    var itemSelected = function(e, ui) {
      $('#autocomplete_label').val(ui.item.label);
      $('#adoption_dog_id').val(ui.item.value);
      return false;
    };

    var focusEvent = function(event, ui) {
      $('#autocomplete_label').val(ui.item.label);
      return false;
    };

    var responseHandler = function(event, ui) {
      if (ui.content.length == 1) {
        $('#autocomplete_label').blur();
        ui.item = ui.content[0];
        $(this).data('ui-autocomplete')._trigger('select', 'autocompleteselect', ui);
        $(this).autocomplete('close');
      }
    };

    $('.autocomplete')
      .autocomplete({
        focus: focusEvent,
        minLength: 2,
        response: responseHandler,
        select: itemSelected,
        source: remoteSource
      });
  }
});
{'fraction_non_alphanumeric': 0.17093658126837463, 'fraction_numerical': 0.0033599328013439733, 'mean_word_length': 2.4571843251088534, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961325', 'n_tokens_mistral': 744, 'n_tokens_neox': 719, 'n_words': 131}