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

Only allow to select items from items list? #414

Closed
silentHoo opened this issue Mar 9, 2017 · 3 comments
Closed

Only allow to select items from items list? #414

silentHoo opened this issue Mar 9, 2017 · 3 comments

Comments

@silentHoo
Copy link

silentHoo commented Mar 9, 2017

Hey everybody,

thanks for the nice component. I'm searching for a solution to use this combo box as simple dropdown in some cases but I couldn't find a way to just select items from the given items attribute.

When I use <vaadin-combo-box allow-custom-value="false"> I can input any value into the input field. Is this really the intended behaviour?

@web-padawan
Copy link
Member

web-padawan commented Mar 9, 2017

This is how boolean attributes work: if you set the attribute, it means true, if you remove it - it means false. You cannot pass false in a way you do it, so just remove attribute and you will be fine. You can use data bindings to specify if custom value should be allowed, though.

@jouni
Copy link
Member

jouni commented Mar 9, 2017

If you don’t want to allow the user to type into the field, and only open the dropdown when the field is clicked, you can use vaadin-combo-box-light, and use a read-only input element instead. Here’s a quick example: http://jsbin.com/loqobonake/edit?html,output

From there, you can style the input to look like something else if needed.

@silentHoo
Copy link
Author

@web-padawan, @jouni: Thanks for the input. This works! 👍

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

No branches or pull requests

3 participants