Events
| Property | Type | Description |
|---|---|---|
on_type | function | (optional) Will be called for every key change the users makes. Returns an object with the input value inside { value, event, attributes } including these methods |
on_focus | function | (optional) Will be called on user generated focus action. Returns an object with the input value inside { value, event, attributes } including these methods. |
on_blur | function | (optional) Will be called on user generated blur action. Returns an object with the input value inside { value, event, attributes } including these methods. |
on_change | function | (optional) Will be called on state changes made by the user. Returns an object with the new selected data item { data, event, attributes, value } including these methods. |
on_select | function | (optional) Will be called once the users focuses or selects an item by a click or keyboard navigation. Returns an object with the new selected data item { data, event, attributes, value, active_item } including these methods. The "active_item" property is the currently selected item by keyboard navigation |
on_show | function | (optional) Will be called once the user presses the autocomplete. Returns the data item { data, attributes }. |
on_hide | function | (optional) Will be called once the user presses the autocomplete again, or clicks somewhere else. Returns the data item { data, attributes }. |
The on_change vs on_select difference
The difference between on_change and on_select is:
on_changewill be called when the state changes, either with a click or space/enter keypress confirmation.on_selectdiffers most when the user is navigating by keyboard. Once the user is pressing e.g. the arrow keys, the selection is changing, but not the state.
Dynamically change data
You can manipulate the used data dynamically, either by changing the data property or during user events like on_type or on_focus. The following properties and methods are there to use:
Methods
updateDatareplace all data entries.emptyDataremove all data entries.resetSelectedItemwill invalidate the selected key.revalidateSelectedItemwill re-validate the internal selected key on the givenvalue.revalidateInputValuewill re-validate the current input value and update it – based on the givenvalue.setInputValueupdate the input value.clearInputValuewill set the current input value to an empty string.focusInputwill set focus on the input element.showIndicatorshows a progress indicator instead of the icon (inside the input).hideIndicatorhides the progress indicator inside the input.showIndicatorItemshows an item with a ProgressIndicator status as an data option item.showNoOptionsItemshows the "no entries found" status as an data option item.setVisibleshows the DrawerList.setHiddenhides the DrawerList.showAllItemsshows all DrawerList items.setModeswitch the mode during runtime.debouncea debounce method with a cancel invocation method on repeating calls. There is more documentation about this method.
Properties
dataListcontains all the data entries.
Example
<Autocompleteon_focus={({ updateData, showIndicator }) => {showIndicator()setTimeout(() => {updateData(topMovies)}, 1e3)}}on_type={({ value /* updateData, ... */ }) => {console.log('on_type', value)}}/>