Vaadin-combo-box: Make it possible to programmatically focus the vaadin-combo-box

Created on 25 Nov 2016  ·  4Comments  ·  Source: vaadin/vaadin-combo-box

It would be nice if you could add a focus function to the vaadin-combo-box to focus it programmatically.
For now im using comboBoxElement.$.input.focus() but it doesn't feels right to access the inner Element and with a focus function it would behave like a "normal" HTMLElement.

Most helpful comment

Good idea 👍 I'll keep this issue open for further discussion within our team. Implementation is simple, but we are careful of not adding unnecessary functions/properties to our elements. Deprecating and removing a function from our API is always an hassle 😸

All 4 comments

Good idea 👍 I'll keep this issue open for further discussion within our team. Implementation is simple, but we are careful of not adding unnecessary functions/properties to our elements. Deprecating and removing a function from our API is always an hassle 😸

Adding API shouldn't be an issue since focus() is part of the native HTML element and thus is already included.

We could use the same approach which <paper-input> uses by making the host element focusable and delegating the focus and blur events down to the inner <input> element.

@samiheikki this isn't unnecessary -- it is a requirement for business apps to be able to set focus on an input control :-).

FWIW, this is easy to do by working directly with the input:

this.$.comboBox.$.input.focus()

But of course this is using a child component (which isn't safe), and I'm not sure this works when shadow DOM is enabled.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anasmi picture anasmi  ·  18Comments

osamamaruf picture osamamaruf  ·  4Comments

OlliTietavainenVaadin picture OlliTietavainenVaadin  ·  6Comments

joostdebruijn picture joostdebruijn  ·  6Comments

silentHoo picture silentHoo  ·  3Comments