In several places where a custom version of <datalist>
is implemented, it is used to provide suggestions multiple times, namely each time users insert one of the listed values or when a specific “separator” character (comma, dot, space, hyphen, pipe) is typed. Just think about social network tag systems, or even in the “choose optional tags” box under new topics here on WICG.
Unfortunately, the suitable form control for this kind of input is type=text
, which cannot have a multiple value. This is correct, because text input accepts free-form text: a separator can be an input character as well and this cannot be foreseen.
But I strongly believe that this should be modified. In particular, I would suggest two changes:
- The possibility to indicate a character used as separator for the control
- The possibility to show the suggestion list when said separator is typed.
As I said, the first is necessary: this way programmers can specify what separator(s) to use, employing characters not used in suggestions. It should be discussed whether UAs are expected to send control data as a single field or as a collection (the same way a multiple <select>
is expected to work).
The second, which is the core of my proposal, can be achieved in two ways:
- Natively: the browser resets list filter and shows it when separator character is typed.
- As API: the form control could really use a method to show the list itself (and maybe filter it). This way authors could replicate initial datalist behavior on request (namely when the separator is typed).
What do you think? Is it viable?