How to display datalist when selecting the entire input element content and pressing delete?

Viewed 24

I have a HTML input element and an associated datalist.

<input list="product_list" id="product_input">
    <datalist id="product_list">
    </datalist>

It works fine and what is displayed in the datalist is correctly updated when the user types in or delete characters in the input. However if the user selects the entire content of the input (either by pressing Ctrl+A or by using the mouse) and press delete, the input is correctly emptied but the datalist does not update.

Currently, to update the datalist, the user needs to click on the input field after deleting its content for the datalist to update. Is there a way to avoid doing this additional click and simply having the datalist updating when removing the content of the input element?

Thank you

0 Answers
Related