Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a cleaned up version of #16852 (sequence #16821 -> #16851 -> #16852 -> this PR)
It is now possible to show a suggestion label in completer, but insert a suggestion value into the input instead.
In addition to String as before, each list item now can also be:
{ label, value }
Object[ label, value ]
ArrayTo show full country name in completer, but insert country code into the input you can use these items:
{ label: "United States", value: "US" }
[ "United States", "US" ]
Despite this data format change, old code will continue to work as before. This is taken care by
Suggestion()
. It useslabel
property automatically when string is expected anywhere in the API.One known issue is that accessing suggestion's characters by index won't work with old API. It's easy to fix though. Instead of
item[idx]
useitem.value[idx]
oritem.label[idx]
directly.In addition to default support for String/Object/Array items, we also add
data
method, which can be used to support any additional custom item formats and to generate data dynamically, as in changed Email example. The only thing you need to do in this case is to return item in any of String/Array/Object formats supported by default.Initialization via
<datalist>
or<ul>
with separatelabel/value
is supported as well.