Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to create new chips in autocomplete mode #59

Open
ainvaltin opened this issue Nov 9, 2017 · 5 comments
Open

Allow to create new chips in autocomplete mode #59

ainvaltin opened this issue Nov 9, 2017 · 5 comments

Comments

@ainvaltin
Copy link

Add property allowAdd which when set to true would allow to create new chip in input even when the entered text is not present in the datasource.

@ndormont
Copy link

ndormont commented Nov 9, 2017

+1

@leogr
Copy link
Collaborator

leogr commented Nov 28, 2017

Nice feature!

PRs are welcome!

@leodido
Copy link
Collaborator

leodido commented Jan 9, 2018

This feature would be nice but I wonder which value/key we'll use for a new chip (with a label not present in the datasource) ...

@ainvaltin
Copy link
Author

The label (aka display-property) for the new chip would be the text user entered into input field. The value would be undefined. Perhaps there could be a property user can assign callback func which inits new chip's object (ie assigns value property), but IMO it would have to work without it too...

I'm not familiar with the inner workings of this component, does it require (unique?) key for each chip? Does it make sense to say that when the chip doesn't have key assigned it is considered to be NULL and each NULL is distinct from other NULLs (like in relational database)?

@leogr
Copy link
Collaborator

leogr commented Jan 9, 2018

@ainvaltin that's dirty.

Currently, paper-chip-input is using datasource content as data source. For each object within data source, the object's property named value (or as defined by value-property attribute) is used as unique value identifiers. Thus, values will contains an array of those values (duplicates are removed automatically).

The label is a different thing. Value and label may be different. Just as example, the mobile Gmail app shows the name of your contact (instead of the email address) if address book has it.

paper-chip-input and paper-chip work in a similar way the native select does:

<select>
<option value="1">label one</option>
<option value="2">label two</option>
</select>

and for the same reason value cannot be undefined (the label is used in case value is not set).

Your case can only work when the label is used as value. When a new text is entered, we could add to the datasource using the same value for the value and the label.
That's the same thing that happens when in the GMail app you enter an email address that's not present in your address book. That's also a simply solution.

PRs are welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants