simple-svelte-autocomplete
simple-svelte-autocomplete copied to clipboard
Programatically clear input
I have bound a variable to selectedItem. When i clear the bound variable (set it to undefined or null) it does not reflect in the input field. Is there a way to clear it programatically? Reproduction here
Based on the comments in #174, I did this:
const autocompleteClearButton = document.querySelector('span.autocomplete-clear-button');
if (autocompleteClearButton)
autocompleteClearButton.click();
This requires the button to be enabled by setting the showClear
property.