Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@algolia/autocomplete-shared

algolia3.8mMIT1.19.0TypeScript support: included

Shared utils for Autocomplete packages.

readme

⚠️ Deprecation notice

Autocomplete.js (v0.x) is deprecated and no longer supported. Please use Autocomplete instead. To upgrade from v0.x, please follow our upgrade guide.

Autocomplete.js

This JavaScript library adds a fast and fully-featured auto-completion menu to your search box displaying results "as you type". It can easily be combined with Algolia's realtime search engine. The library is available as a jQuery plugin, an Angular.js directive or a standalone library.

build status NPM version Coverage Status jsDelivr Hits jQuery Zepto.js Angular.js License: MIT

Browser tests

Table of Contents

Features

  • Displays suggestions to end-users as they type
  • Shows top suggestion as a hint (i.e. background text)
  • Supports custom templates to allow for UI flexibility
  • Works well with RTL languages and input method editors
  • Triggers custom events

Installation

The autocomplete.js library must be included after jQuery, Zepto or Angular.js (with jQuery). Else, it will use the embedded Zepto.

jsDelivr

<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.min.js"></script>
<!-- OR -->
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.jquery.min.js"></script>
<!-- OR -->
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.angular.min.js"></script>

cdnjs

<script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/<VERSION>/autocomplete.min.js"></script>
<!-- OR -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/<VERSION>/autocomplete.jquery.min.js"></script>
<!-- OR -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/autocomplete.js/<VERSION>/autocomplete.angular.min.js"></script>

npm

npm install --save autocomplete.js

Bower

bower install algolia-autocomplete.js -S

Source dist/

You can find the built version in dist/.

Browserify

You can require it and use Browserify:

var autocomplete = require('autocomplete.js');

Usage

Standalone

  1. Include autocomplete.min.js
  2. Initialize the auto-completion menu calling the autocomplete function

    Warning: autocomplete.js is not compatible with the latest version algoliasearch v4 out of the box, but you can create a compatibility source by yourself like this:

<input type="text" id="search-input" placeholder="Search unicorns..." />

<!-- [ ... ] -->
<script src="https://cdn.jsdelivr.net/npm/algoliasearch@4/dist/algoliasearch.umd.min.js"></script>
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.min.js"></script>
<script>
  var client = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey');
  var index = client.initIndex('YourIndex');

  function newHitsSource(index, params) {
    return function doSearch(query, cb) {
      index
        .search(query, params)
        .then(function(res) {
          cb(res.hits, res);
        })
        .catch(function(err) {
          console.error(err);
          cb([]);
        });
    };
  }

  autocomplete('#search-input', { hint: false }, [
    {
      source: newHitsSource(index, { hitsPerPage: 5 }),
      displayKey: 'my_attribute',
      templates: {
        suggestion: function(suggestion) {
          return suggestion._highlightResult.my_attribute.value;
        }
      }
    }
  ]).on('autocomplete:selected', function(event, suggestion, dataset, context) {
    console.log(event, suggestion, dataset, context);
  });
</script>

jQuery

  1. Include autocomplete.jquery.min.js after including jQuery
  2. Initialize the auto-completion menu calling the autocomplete jQuery plugin

    Warning: autocomplete.js is not compatible with the latest version algoliasearch v4, therefore we highly recommend you use algoliasearch v3 as specified in the code snippet below.

<input type="text" id="search-input" />

<!-- [ ... ] -->
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.min.js"></script>
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.jquery.min.js"></script>
<script>
  var client = algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey')
  var index = client.initIndex('YourIndex');
  $('#search-input').autocomplete({ hint: false }, [
    {
      source: $.fn.autocomplete.sources.hits(index, { hitsPerPage: 5 }),
      displayKey: 'my_attribute',
      templates: {
        suggestion: function(suggestion) {
          return suggestion._highlightResult.my_attribute.value;
        }
      }
    }
  ]).on('autocomplete:selected', function(event, suggestion, dataset, context) {
    console.log(event, suggestion, dataset, context);
  });
</script>

Angular.JS

  1. Include autocomplete.angular.min.js after including jQuery & Angular.js
  2. Inject the algolia.autocomplete module
  3. Add the autocomplete, aa-datasets and the optional aa-options attribute to your search bar

    Warning: autocomplete.js is not compatible with the latest version algoliasearch v4, therefore we highly recommend you use algoliasearch v3 as specified in the code snippet below.

<div ng-controller="yourController">
  <input type="text" id="search-input" autocomplete aa-datasets="getDatasets()" />
</div>

<!-- [ include jQuery + Angular.js ] -->
<script src="https://cdn.jsdelivr.net/algoliasearch/3/algoliasearch.angular.min.js"></script>
<script src="https://cdn.jsdelivr.net/autocomplete.js/0/autocomplete.angular.min.js"></script>
<script>
  angular.module('myApp', ['algoliasearch', 'algolia.autocomplete'])
    .controller('yourController', ['$scope', 'algolia', function($scope, algolia) {
      var client = algolia.Client('YourApplicationID', 'YourSearchOnlyAPIKey');
      var index = client.initIndex('YourIndex');

      $scope.getDatasets = function() {
        return {
          source: algolia.sources.hits(index, { hitsPerPage: 5 }),
          displayKey: 'my_attribute',
          templates: {
            suggestion: function(suggestion) {
              return suggestion._highlightResult.my_attribute.value;
            }
          }
        };
      };

      $scope.$on('autocomplete:selected', function(event, suggestion, dataset) {
        console.log(event, suggestion, dataset, context);
      });
    }]);
</script>

Note: You need to rely on jQuery, the lite version embedded in Angular.js won't work.

Look and Feel

Below is a faux mustache template describing the DOM structure of an autocomplete dropdown menu. Keep in mind that header, footer, suggestion, and empty come from the provided templates detailed here.

<span class="aa-dropdown-menu{{#datasets}} aa-{{'with' or 'without'}}-{{name}}{{/datasets}}">
  {{#datasets}}
    <div class="aa-dataset-{{name}}">
      {{{header}}}
      <span class="aa-suggestions">
        {{#suggestions}}
          <div class="aa-suggestion">{{{suggestion}}}</div>
        {{/suggestions}}
        {{^suggestions}}
          {{{empty}}}
        {{/suggestions}}
      </span>
      {{{footer}}}
    </div>
  {{/datasets}}
  {{empty}}
</span>

When an end-user mouses or keys over a .aa-suggestion, the class aa-cursor will be added to it. You can use this class as a hook for styling the "under cursor" state of suggestions.

Add the following CSS rules to add a default style:

.algolia-autocomplete {
  width: 100%;
}
.algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint {
  width: 100%;
}
.algolia-autocomplete .aa-hint {
  color: #999;
}
.algolia-autocomplete .aa-dropdown-menu {
  width: 100%;
  background-color: #fff;
  border: 1px solid #999;
  border-top: none;
}
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion {
  cursor: pointer;
  padding: 5px 4px;
}
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor {
  background-color: #B2D7FF;
}
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em {
  font-weight: bold;
  font-style: normal;
}

Here is what the basic example looks like:

Basic example

Global Options

When initializing an autocomplete, there are a number of global options you can configure.

  • autoselect – If true, the first rendered suggestion in the dropdown will automatically have the cursor class, and pressing <ENTER> will select it.

  • autoselectOnBlur – If true, when the input is blurred, the first rendered suggestion in the dropdown will automatically have the cursor class, and pressing <ENTER> will select it. This option should be used on mobile, see #113

  • tabAutocomplete – If true, pressing tab will select the first rendered suggestion in the dropdown. Defaults to true.

  • hint – If false, the autocomplete will not show a hint. Defaults to true.

  • debug – If true, the autocomplete will not close on blur. Defaults to false.

  • clearOnSelected – If true, the autocomplete will empty the search box when a suggestion is selected. This is useful if you want to use this as a way to input tags using the selected event.

  • openOnFocus – If true, the dropdown menu will open when the input is focused. Defaults to false.

  • appendTo – If set with a DOM selector, doesn't wrap the input and appends the wrapper and dropdown menu to the first DOM element matching the selector. It automatically positions the wrapper under the input, and sets it to the same width as the input. Can't be used with hint: true, because hint requires the wrapper around the input.

  • dropdownMenuContainer – If set with a DOM selector, it overrides the container of the dropdown menu.

  • templates – An optional hash overriding the default templates.

    • dropdownMenu – the dropdown menu template. The template should include all dataset placeholders.
    • header – the header to prepend to the dropdown menu
    • footer – the footer to append to the dropdown menu
    • empty – the template to display when none of the datasets are returning results. The templating function is called with a context containing the underlying query.
  • cssClasses – An optional hash overriding the default css classes.

    • root – the root classes. Defaults to algolia-autocomplete.
    • prefix – the CSS class prefix of all nested elements. Defaults to aa.
    • noPrefix - set this to true if you wish to not use any prefix. Without this option, all nested elements classes will have a leading dash. Defaults to false.
    • dropdownMenu – the dropdown menu CSS class. Defaults to dropdown-menu.
    • input – the input CSS class. Defaults to input.
    • hint – the hint CSS class. Defaults to hint.
    • suggestions – the suggestions list CSS class. Defaults to suggestions.
    • suggestion – the suggestion wrapper CSS class. Defaults to suggestion.
    • cursor – the cursor CSS class. Defaults to cursor.
    • dataset – the dataset CSS class. Defaults to dataset.
    • empty – the empty CSS class. Defaults to empty.
  • keyboardShortcuts - Array of shortcut that will focus the input. For example if you want to bind s and / you can specify: keyboardShortcuts: ['s', '/']

  • ariaLabel - An optional string that will populate the aria-label attribute.

<script type="text/template" id="my-custom-menu-template">
  <div class="my-custom-menu">
    <div class="row">
      <div class="col-sm-6">
        <div class="aa-dataset-d1"></div>
      </div>
      <div class="col-sm-6">
        <div class="aa-dataset-d2"></div>
        <div class="aa-dataset-d3"></div>
      </div>
    </div>
  </div>
</script>
<style>
body {
    font-family: -apple-system, sans-serif;
}
.algolia-autocomplete {
  width: 100%;
}
.algolia-autocomplete .aa-input, .algolia-autocomplete .aa-hint {
  width: 100%;
}
.algolia-autocomplete .aa-hint {
  color: #999;
}
.algolia-autocomplete .aa-dropdown-menu {
  width: 100%;
  background-color: #fff;
  border: 1px solid #999;
  border-top: none;
}
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion {
  cursor: pointer;
  padding: 5px 4px;
}
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion.aa-cursor {
  background-color: #B2D7FF;
}
.algolia-autocomplete .aa-dropdown-menu .aa-suggestion em {
  font-weight: bold;
  font-style: normal;
}

.branding {
font-size: 1.3em;
margin: 0.5em 0.2em;
}

.branding img {
    height: 1.3em;
    margin-bottom: - 0.3em;
}
</style>
<script>
  $('#search-input').autocomplete(
    {
      templates: {
        dropdownMenu: '#my-custom-menu-template',
        footer: '<div class="branding">Powered by <img src="https://www.algolia.com/static_assets/images/press/downloads/algolia-logo-light.svg" /></div>'
      }
    },
    [
      {
        source: $.fn.autocomplete.sources.hits(index1, { hitsPerPage: 5 }),
        name: 'd1',
        templates: {
          header: '<h4>List 1</h4>',
          suggestion: function(suggestion) {
            // FIXME
          }
        }
      },
      {
        source: $.fn.autocomplete.sources.hits(index2, { hitsPerPage: 2 }),
        name: 'd2',
        templates: {
          header: '<h4>List 2</h4>',
          suggestion: function(suggestion) {
            // FIXME
          }
        }
      },
      {
        source: $.fn.autocomplete.sources.hits(index3, { hitsPerPage: 2 }),
        name: 'd3',
        templates: {
          header: '<h4>List 3</h4>',
          suggestion: function(suggestion, answer) {
            // FIXME
          }
        }
      }
    ]
  );
</script>
  • minLength – The minimum character length needed before suggestions start getting rendered. Defaults to 1.

  • autoWidth – This option allow you to control the width of autocomplete wrapper. When false the autocomplete wrapper will not have the width style attribute and you are be able to put your specific width property in your css to control the wrapper. Default value is true.

One scenario for use this option. e.g. You have a max-width css attribute in your autocomplete-dropdown-menu and you need to width grows until fill the max-width. In this scenario you put a width: auto in your autocomplete wrapper css class and the max-width in your autocomplete dropdown class and all done.

Datasets

An autocomplete is composed of one or more datasets. When an end-user modifies the value of the underlying input, each dataset will attempt to render suggestions for the new value.

Datasets can be configured using the following options.

  • source – The backing data source for suggestions. Expected to be a function with the signature (query, cb). It is expected that the function will compute the suggestion set (i.e. an array of JavaScript objects) for query and then invoke cb with said set. cb can be invoked synchronously or asynchronously.

  • name – The name of the dataset. This will be appended to tt-dataset- to form the class name of the containing DOM element. Must only consist of underscores, dashes, letters (a-z), and numbers. Defaults to a random number.

  • displayKey – For a given suggestion object, determines the string representation of it. This will be used when setting the value of the input control after a suggestion is selected. Can be either a key string or a function that transforms a suggestion object into a string. Defaults to value. Example function usage: displayKey: function(suggestion) { return suggestion.nickname || suggestion.firstName }

  • templates – A hash of templates to be used when rendering the dataset. Note a precompiled template is a function that takes a JavaScript object as its first argument and returns a HTML string.

    • empty – Rendered when 0 suggestions are available for the given query. Can be either a HTML string or a precompiled template. The templating function is called with a context containing query, isEmpty, and any optional arguments that may have been forwarded by the source: function emptyTemplate({ query, isEmpty }, [forwarded args]).

    • footer – Rendered at the bottom of the dataset. Can be either a HTML string or a precompiled template. The templating function is called with a context containing query, isEmpty, and any optional arguments that may have been forwarded by the source: function footerTemplate({ query, isEmpty }, [forwarded args]).

    • header – Rendered at the top of the dataset. Can be either a HTML string or a precompiled template. The templating function is called with a context containing query, isEmpty, and any optional arguments that may have been forwarded by the source: function headerTemplate({ query, isEmpty }, [forwarded args]).

    • suggestion – Used to render a single suggestion. The templating function is called with the suggestion, and any optional arguments that may have been forwarded by the source: function suggestionTemplate(suggestion, [forwarded args]). Defaults to the value of displayKey wrapped in a p tag i.e. <p>{{value}}</p>.

  • debounce – If set, will postpone the source execution until after debounce milliseconds have elapsed since the last time it was invoked.

  • cache - If set to false, subsequent identical queries will always execute the source function for suggestions. Defaults to true.

Sources

A few helpers are provided by default to ease the creation of Algolia-based sources.

Hits

To build a source based on Algolia's hits array, just use:

{
  source: autocomplete.sources.hits(indexObj, { hitsPerPage: 2 }),
  templates: {
    suggestion: function(suggestion, answer) {
      // FIXME
    }
  }
}

PopularIn (aka "xxxxx in yyyyy")

To build an Amazon-like autocomplete menu, suggesting popular queries and for the most popular one displaying the associated categories, you can use the popularIn source:

{
  source: autocomplete.sources.popularIn(popularQueriesIndexObj, { hitsPerPage: 3 }, {
    source: 'sourceAttribute',           // attribute of the `popularQueries` index use to query the `index` index
    index: productsIndexObj,             // targeted index
    facets: 'facetedCategoryAttribute',  // facet used to enrich the most popular query
    maxValuesPerFacet: 3                 // maximum number of facets returned
  }, {
    includeAll: true,                    // should it include an extra "All department" suggestion
    allTitle: 'All departments'          // the included category label
  }),
  templates: {
    suggestion: function(suggestion, answer) {
      var value = suggestion.sourceAttribute;
      if (suggestion.facet) {
        // this is the first suggestion
        // and it has been enriched with the matching facet
        value += ' in ' + suggestion.facet.value + ' (' + suggestion.facet.count + ')';
      }
      return value;
    }
  }
}

Custom source

The source options can also take a function. It enables you to have more control of the results returned by Algolia search. The function function(query, callback) takes 2 parameters

  • query: String: the text typed in the autocomplete
  • callback: Function: the callback to call at the end of your processing with the array of suggestions
source: function(query, callback) {
  var index = client.initIndex('myindex');
  index.search(query, { hitsPerPage: 1, facetFilters: 'category:mycat' }).then(function(answer) {
    callback(answer.hits);
  }, function() {
    callback([]);
  });
}

Or by reusing an existing source:

var hitsSource = autocomplete.sources.hits(index, { hitsPerPage: 5 });

source: function(query, callback) {
  hitsSource(query, function(suggestions) {
    // FIXME: Do stuff with the array of returned suggestions
    callback(suggestions);
  });
}

Security

User-generated data: protecting against XSS

Malicious users may attempt to engineer XSS attacks by storing HTML/JS in their data. It is important that user-generated data be properly escaped before using it in an autocomplete.js template.

In order to easily do that, autocomplete.js provides you with a helper function escaping all HTML code but the highlighting tags:

  templates: {
    suggestion: function(suggestion) {
      var val = suggestion._highlightResult.name.value;
      return autocomplete.escapeHighlightedString(val);
    }
  }

If you did specify custom highlighting pre/post tags, you can specify them as 2nd and 3rd parameter:

  templates: {
    suggestion: function(suggestion) {
      var val = suggestion._highlightResult.name.value;
      return autocomplete.escapeHighlightedString(val, '<span class="highlighted">', '</span>');
    }
  }

FAQ

How can I Control-click on results and have them open in a new tab?

You'll need to update your suggestion templates to make them as <a href> links and not simple divs. Control-clicking on them will trigger the default browser behavior and open suggestions in a new tab.

To also support keyboard navigation, you'll need to listen to the autocomplete:selected event and change window.location to the destination URL.

Note that you might need to check the value of context.selectionMethod in autocomplete:selected first. If it's equal to click, you should return early, otherwise your main window will also follow the link.

Here is an example of how it would look like:

autocomplete(…).on('autocomplete:selected', function(event, suggestion, dataset, context) {
  // Do nothing on click, as the browser will already do it
  if (context.selectionMethod === 'click') {
    return;
  }
  // Change the page, for example, on other events
  window.location.assign(suggestion.url);
});

Events

The autocomplete component triggers the following custom events.

  • autocomplete:opened – Triggered when the dropdown menu of the autocomplete is opened.

  • autocomplete:shown – Triggered when the dropdown menu of the autocomplete is shown (opened and non-empty).

  • autocomplete:empty – Triggered when all datasets are empty.

  • autocomplete:closed – Triggered when the dropdown menu of the autocomplete is closed.

  • autocomplete:updated – Triggered when a dataset is rendered.

  • autocomplete:cursorchanged – Triggered when the dropdown menu cursor is moved to a different suggestion. The event handler will be invoked with 3 arguments: the jQuery event object, the suggestion object, and the name of the dataset the suggestion belongs to.

  • autocomplete:selected – Triggered when a suggestion from the dropdown menu is selected. The event handler will be invoked with the following arguments: the jQuery event object, the suggestion object, the name of the dataset the suggestion belongs to and a context object. The context contains a .selectionMethod key that can be either click, enterKey, tabKey or blur, depending how the suggestion was selected.

  • autocomplete:cursorremoved – Triggered when the cursor leaves the selections or its current index is lower than 0

  • autocomplete:autocompleted – Triggered when the query is autocompleted. Autocompleted means the query was changed to the hint. The event handler will be invoked with 3 arguments: the jQuery event object, the suggestion object, and the name of the dataset the suggestion belongs to.

  • autocomplete:redrawn – Triggered when appendTo is used and the wrapper is resized/repositionned.

All custom events are triggered on the element initialized as the autocomplete.

API

jQuery

Turns any input[type="text"] element into an auto-completion menu. globalOptions is an options hash that's used to configure the autocomplete to your liking. Refer to Global Options for more info regarding the available configs. Subsequent arguments (*datasets), are individual option hashes for datasets. For more details regarding datasets, refer to Datasets.

$(selector).autocomplete(globalOptions, datasets)

Example:

$('.search-input').autocomplete({
  minLength: 3
},
{
  name: 'my-dataset',
  source: mySource
});

jQuery#autocomplete('destroy')

Removes the autocomplete functionality and reverts the input element back to its original state.

$('.search-input').autocomplete('destroy');

jQuery#autocomplete('open')

Opens the dropdown menu of the autocomplete. Note that being open does not mean that the menu is visible. The menu is only visible when it is open and has content.

$('.search-input').autocomplete('open');

jQuery#autocomplete('close')

Closes the dropdown menu of the autocomplete.

$('.search-input').autocomplete('close');

jQuery#autocomplete('val')

Returns the current value of the autocomplete. The value is the text the user has entered into the input element.

var myVal = $('.search-input').autocomplete('val');

jQuery#autocomplete('val', val)

Sets the value of the autocomplete. This should be used in place of jQuery#val.

$('.search-input').autocomplete('val', myVal);

jQuery.fn.autocomplete.noConflict()

Returns a reference to the autocomplete plugin and reverts jQuery.fn.autocomplete to its previous value. Can be used to avoid naming collisions.

var autocomplete = jQuery.fn.autocomplete.noConflict();
jQuery.fn._autocomplete = autocomplete;

Standalone

The standalone version API is similiar to jQuery's:

var search = autocomplete(containerSelector, globalOptions, datasets);

Example:

var search = autocomplete('#search', { hint: false }, [{
  source: autocomplete.sources.hits(index, { hitsPerPage: 5 })
}]);

search.autocomplete.open();
search.autocomplete.close();
search.autocomplete.getVal();
search.autocomplete.setVal('Hey Jude');
search.autocomplete.destroy();
search.autocomplete.getWrapper(); // since autocomplete.js wraps your input into another div, you can access that div

You can also pass a custom Typeahead instance in Autocomplete.js constructor:

var search = autocomplete('#search', { hint: false }, [{ ... }], new Typeahead({ ... }));

autocomplete.noConflict()

Returns a reference to the autocomplete plugin and reverts window.autocomplete to its previous value. Can be used to avoid naming collisions.

var algoliaAutocomplete = autocomplete.noConflict();

Contributing & releasing

see CONTRIBUTING.md

Credits

This library has originally been forked from Twitter's typeahead.js library.

changelog

0.38.1 (2021-12-13)

0.38.0 (2020-09-17)

Features

0.37.1 (2020-01-27)

Bug Fixes

  • algolia: parse user agents with new search clients (#302) (2f32ffb)
  • zepto: catch exceptions while assigning (#298) (652bde4)

0.37.0 (2019-08-30)

Bug Fixes

  • clear: Avoid error when clear is called after destroy (#287) (244425d)

0.36.0 (2019-02-21)

Bug Fixes

  • standalone: use aria label from input (#276) (4b94466)

0.35.0 (2018-12-17)

Bug Fixes

  • chrome-only: Change autocomplete from 'nope' to 'off' (#273) (892a8f0)
  • utils: correct _.every method (#274) (55af1e3)

0.34.0 (2018-12-04)

Features

  • change autocomplete from 'off' to 'nope' (#250) (fbbed04)

0.33.0 (2018-11-19)

Bug Fixes

Features

  • selected: Adding context.selectionMethod to selected event (#267) (36028a6)

0.32.0 (2018-11-06)

Bug Fixes

  • zepto: apply patch to prevent an error (#263) (917d5a7)

Features

  • source: add cache disabling for datasets (#254) (0e65fee)
  • add flag for toggling tab autocompletion (#260) (4dc7c52)
  • Throw err on update if suggestions are invalid type (#256) (179febf), closes #131

0.31.0 (2018-08-08)

Bug Fixes

  • dataset: avoid to call the source when upadte is canceled (a47696d)
  • dataset: avoid usage of callNow for debounce (1a0ce74)
  • Handle an odd case with the user agent (#242) (c194736)

Features

  • update dist files (9babf2e)
  • clearOnSelected: allow users to clear the input instead of filling (#244) (aa2edbb), closes #241

0.30.0 (2018-04-30)

0.29.0 (2017-10-12)

Features

  • a11y: Add ariaLabel option. (6db8e1b)
  • a11y: Add option to control aria-labelledby attribute. (0491c43)

0.28.3 (2017-07-31)

0.28.2 (2017-06-22)

Bug Fixes

  • empty template: hide main empty template as long as we have results (344e225), closes #185

0.28.1 (2017-03-29)

Bug Fixes

  • iOS: remove double tap bug on hrefs in suggestions (e532bd8)

0.28.0 (2017-03-24)

0.27.0 (2017-03-06)

Bug Fixes

  • UA: add failsafe if params not provided (30df97a), closes #166

0.26.0 (2017-02-28)

Bug Fixes

  • test: bad handling of no actual inner mechanics of client (622aec5)

Features

  • algolia agent: provide an algolia agent when searching (6ca7ac2)
  • algolia agent: provide an algolia agent when searching (ef604e1)

0.25.0 (2017-02-07)

Bug Fixes

  • zepto: .is() only accepts selectors, reworked code to use pure DOM (a47a4d4), closes #144

0.24.2 (2017-01-20)

Bug Fixes

  • dep: immediate is a dependency, not a devDependency (22164ad)

0.24.1 (2017-01-20)

Bug Fixes

  • postMessage: avoid using postMessage when feasible (a99f664), closes #142

0.24.0 (2017-01-10)

Bug Fixes

  • angular: do not launch the directive if autocomplete has a value (f96a1ba), closes #136
  • typeahead: propagate redrawn (82293e4)

Features

  • appendTo: new parameter (e40cbd0)

0.23.0 Dec 14, 2016

  • feat(build): add noConflict() for standalone build, fixes #133

0.22.1 Nov 07, 2016

  • Fixes bad behavior when autoselectOnBlur used, fixes #113

0.22.0 Oct 25, 2016

  • Add autocomplete:cursorremoved event, see #105
  • Add autoselectOnBlur option, fixes #113

0.21.8 Oct 3, 2016

  • Do not allow Zepto to leak to window. Never.

0.21.7 Sep 21, 2016

  • Ensure the empty templates get displayed before the footer.
  • Ensure the dataset empty templates are displayed when all datasets are empty.

0.21.6 Sep 20, 2016

  • Make sure we don't leak/override window.Zepto.

0.21.5 Sep 15, 2016

  • While selecting the top suggestion (autoselect=true), do not update the input.

0.21.4 Sep 2, 2016

  • Ensure the cursor selects the first suggestion when the dropdown is shown + send the cursorchanged event.

0.21.3 Aug 1, 2016

  • Ensure empty template displays from first keystroke (#104)

0.21.2 July 26, 2016

  • fix(empty): fix the empty even handling, fixes #95

0.21.1 July 19, 2016

  • fix(getVal): fix getVal on standalone build

0.21.0 July 15, 2016

  • Upgrade to zepto 1.2.0

0.20.1 June 14, 2016

  • Ensure the dropdown menu is hidden when there is an $empty block and blank query.

0.20.0 June 04, 2016

  • Ensure we don't update the input value on mouseenter (#76)
  • Render an empty template if no results (#80)

0.19.1 May 04, 2016

  • Fixed the angular build (_.Event was undefined)

0.19.0 Apr 25, 2016

  • Allow select handler to prevent menu from being closed (#72)
  • Do not trigger the cursorchanged event while entering/leaving nested divs (#71)

0.18.0 Apr 07, 2016

  • Ability to customize the CSS classes used to render the DOM
  • Ensure the autocomplete:cursorchanged event is called on mouseover as well

0.17.3 Apr 04, 2016

  • Standalone: ensure we actually use the Zepto object and not whatever is in window.$

0.17.2 Mar 21, 2016

  • Ability to setup the autocomplete on a multi-inputs Zepto selector
  • Propagate the shown event to the top-level

0.17.1 Mar 19, 2016

  • REVERT [Ability to setup the autocomplete on a multi-inputs Zepto selector] Fix #59

0.17.0 Mar 18, 2016

  • Ability to setup the autocomplete on a multi-inputs Zepto selector
  • Add a new shown event triggered when the dropdown menu is opened and non-empty

BREAKING CHANGE: the standalone object returned by the autocomplete() method is now a Zepto object.

0.16.2 Jan 22, 2016

  • stop using weird zepto package. Stop using chained .data calls it seems that chaining them ended up in an undefined return value when passing undefined as a value

0.16.1 Jan 22, 2016

  • remove npm-zepto, use zepto original package (now on npm) fixes #48

0.16.0 Dec 11, 2015

  • Emit a new autocomplete:updated event as soon as a dataset is rendered

0.15.0 Dec 10, 2015

  • Ability to configure the dropdown menu container

0.14.1 Dec 2, 2015

  • Move Zepto as a dependency (not a peer dep)
  • Really use the query instead of the displayKey (was supposed to be fixed in 0.11.0)

0.14.0 Nov 28, 2015

  • Move npm-zepto & angular to peerDependencies
  • Fixed custom dropdownMenu's footer & header not being displayed properly
  • Allow dataset with name=0

0.13.1 Nov 25, 2015

  • Move the bower release name to algolia-autocomplete.js since autocomplete.js is already used

0.13.0 Nov 25, 2015

  • Add Bower release

0.12.0 Oct 15, 2015

  • Expose the underlying close, open, ... functions in the standalone build.

0.11.1 Oct 13, 2015

  • Zepto doesn't work like jQuery regarding the data API, it doesn't support serializing objects.

0.11.0 Oct 07, 2015

  • If the displayKey is not specified and the value attribute missing, don't update the input value with undefined.
  • Expose the sources object in the Angular.js build as well.

0.10.0 Oct 06, 2015

  • Add a new includeAll option to the popularIn source to add an extra suggestion.

0.9.0 Oct 01, 2015

  • Full CommonJS compliance (moved from browserify to webpack)

0.8.0 Sep 24, 2015

  • UMD compliance

0.7.0 Sep 16, 2015

  • New standalone build (including Zepto.js)
  • Get rid of lodash-compat and use jQuery, Zepto or Angular.js's helper functions

0.6.0 Sep 11, 2015

  • Add Zepto.js support.

0.5.0 Sep 9, 2015

  • The wrapper span will now have a table-cell display if the original input was a block inside a table.

0.4.0 Aug 12, 2015

  • Add a new openOnFocus option to open the dropdown menu when the input is focused

0.3.0 July 27, 2015

  • Add Angular.js support [#7]

0.2.0 July 16, 2015

  • Ability to change the layout based on the matching datasets [#11]

0.1.0 July 13, 2015

  • Start using semantic versioning

0.0.2 July 13, 2015

  • Ability to keep the dropdown menu opened when the input if blurred [#1]
  • Ability to use a custom dropdown menu template [#2]
  • Ability to configure a custom header/footer on the dropdown menu [#3]

0.0.1 July 12, 2015

  • First release based on Twitter's typeahead.js library
  • Travis-ci.org, Coveralls.io, Saucelabs.com integration
  • CommonJS compatibility