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.
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.
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 😸