Vaadin-combo-box: Only allow to select items from items list?

Created on 9 Mar 2017  ·  3Comments  ·  Source: vaadin/vaadin-combo-box

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?

Most helpful comment

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.

All 3 comments

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.

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.

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

osamamaruf picture osamamaruf  ·  4Comments

davidmaxwaterman picture davidmaxwaterman  ·  6Comments

florent1933 picture florent1933  ·  14Comments

web-padawan picture web-padawan  ·  5Comments

sohrabtaee picture sohrabtaee  ·  4Comments