ComboBox maxLength

Hello. I’m trying to set maxLength attribute to the input element in the combobox shadow dom but I cannot find how. How can I access elemtens in the shadom domw and modify them with the element Api? I’m using vaadin 23

The input element is actually not in the shadow DOM, but slotted in the light DOM. Not sure what the best way is to access that through the Java API, but I expect it would be executeJs

Something like comboBox.getElement().executeJs("this.inputElement.maxLength=5")

I’m not sure if that works, I don’t remember exactly how to reference elements via executeJs

It worked! I used this.childNodes.item(0).maxLength = 30. Thank you sir, you solved my problem!

Cool, good to hear. Note that that JS snippet might break in a future release, as you are relying on private implementation details (that the element is the first child element). I would suggest to use this.inputElement if at all possible, as that is more likely to stay working in future releases.