%section.company_search.large-8.large-offset-2.medium-10.medium-offset-1.columns
  = form_for companies_path, method: :get, remote: true do |f|
    .row
      .input-group
        = f.text_field :q, name: 'q', id: "company_search_q", placeholder: t('.placeholder'), class: 'input-group-field', autocomplete: 'off', autofocus: !mobile?
        .input-group-button
          = f.button t('.submit'), class: 'button primary expanded search_bar__right'

:javascript
  var previousVal = '';
  document.getElementById('company_search_q').addEventListener('input', e => {
    let currentVal = e.target.value;
    if (currentVal == previousVal) return;
    previousVal = currentVal;
    if (!currentVal) {
      document.getElementById('companies').innerHTML = '';
      document.getElementById('pagination').innerHTML = '';
    }
    $(e.target.form).trigger('submit.rails');
  });

%section.company_search.large-8.large-offset-2.medium-10.medium-offset-1.columns
  = form_for companies_path, method: :get, remote: true do |f|
    .row
      .input-group
        = f.text_field :q, name: 'q', id: "company_search_q", placeholder: t('.placeholder'), class: 'input-group-field', autocomplete: 'off', autofocus: !mobile?
        .input-group-button
          = f.button t('.submit'), class: 'button primary expanded search_bar__right'

:javascript
  var previousVal, formTimeout;
  document.getElementById('company_search_q').addEventListener('input', e => {
    let currentVal = e.target.value;
    if (currentVal == previousVal) return;
    previousVal = currentVal;
    clearTimeout(formTimeout);
    formTimeout = setTimeout(function() {
      if (!currentVal) {
        document.getElementById('companies').innerHTML = '';
        document.getElementById('pagination').innerHTML = '';
      }
      $(this).trigger('submit.rails');
    }.bind(e.target.form), 100);
  });

Add timeout before firing requests in company search
Add timeout before firing requests in company search
