pstanoev / simple-svelte-autocomplete

Simple Autocomplete / typeahead component for Svelte
http://simple-svelte-autocomplete.surge.sh/
MIT License
464 stars 78 forks source link

Programatically clear input #215

Open jorri11 opened 11 months ago

jorri11 commented 11 months ago

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

rtwfroody commented 9 months ago

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.