Click behaviour on ComboBox

The current behaviour of ComboBox is that it will open if one clicks anywhere inside it. It is causing a problem for me. I set a prefix component (using addToPrefix(...)) and the component I added is a Button. I have my own ClickListener on the Button I added but when I click the Button, the ComboBox is also getting opened.

In my Button’s ClickListener, I can close the ComboBox (setOpened(false)), but this is causing a flicker. Is there a way to control this?

Hi Syam!

I’m curious to hear your use case – what does the button do that you place inside the combo box? Would it make more sense (be less confusing to users) to move the button outside the combo box?

Hi Jouni,
My Combo has a data provider (that fetches data from a DB). This data provider has certain user-definable settings. I was trying to provide a button for allowing the end-users to configure that.
I know that I can use AbstractCompositeField for this but since prefixed component support is already there, I was trying to use that.

Alright, thanks for the description. Yeah, it would be convenient to use a prefix component, I agree. The main purpose for the prefix and suffix slots is, though, to add icons and supplementary text.

There’s not technical limitation for not supporting buttons and links, but for now we haven’t added special support for those (preventing the field from focusing when you press those).

If you want to, you can open an enhancement issue for this in https://github.com/vaadin/vaadin-text-field (it’ll flow from there to combo-box and other components using text-field internally).

Thanks Jouni. Created: [https://github.com/vaadin/vaadin-text-field/issues/225]
(https://github.com/vaadin/vaadin-text-field/issues/225)