Import
JavaScript
Container
Autocomplete now takes a container (for example, a<div>), not an <input>.
Autocomplete generates a fully accessible search box for you.
HTML
Parameters
These parameters and how you use them have changed from Autocomplete v0:| v0 | v1 |
|---|---|
autocomplete('#autocomplete', ...) | autocomplete({ container: '#autocomplete', ...}) |
autoselect: true | defaultActiveItemId: 0 |
autoselectOnBlur: true | No longer needed. This is the default behavior |
tabAutocomplete: true | No longer supported. v1 implements the ARIA 1.1 form of the combobox design pattern |
hint | No longer supported |
clearOnSelected | This is now local to the source: getItemInputValue: () => '' |
dropdownMenuContainer | panelContainer |
templates (top-level) | templates (see also render and renderNoResults) |
cssClasses | classNames where properties have changed |
keyboardShortcuts | No longer supported as an option. Check out the keyboard navigation docs |
minLength: 0 | openOnFocus: true |
Datasets
Datasets are replaced by thegetSources function. Learn more about Sources concept.
Sources
Sources are replaced bygetItems.
Templates
Autocomplete v1 renamed some templates, and uses an agnostic virtual DOM implementation to render them.Return HTML
Unlike in v0, you can no longer return plain HTML strings to inject into the DOM. Yet, you can still return HTML strings using the providedhtml tagged function.
The
html function is available in Autocomplete v1.6.0 and later.If you’re already using a virtual DOM in your app,
you can provide it to Autocomplete and directly return JSX from templates.
Renamed templates
Some templates from v0 were renamed in v1. For more information, see Templates.New renderer.render option
Starting from v1.6.0,
Autocomplete introduces a new render property in the renderer option to pass a custom render function when using Autocomplete with a custom virtual DOM implementation
(React, Vue).
If you were using the render option to specify a custom render function,
you can now remove it and pass the function to renderer instead.
JSX
render option to customize the layout,
you can also use the new renderer.render option and access your custom render function in the provided render parameters.
JSX
Top-level API
JavaScript
Full example
Upgrade the Algolia JavaScript API client from v4 to v5
Upgrading fromalgoliasearch v4 to v5 doesn’t introduce any breaking changes.
However, when you use the query in the search parameters,
you need to use the query parameter instead of the query property.
JavaScript