vaadin / flow-components

Java counterpart of Vaadin Web Components
100 stars 66 forks source link

autoselect attribute not exposed consistently #3408

Open guttormvik2 opened 2 years ago

guttormvik2 commented 2 years ago

Description

TextField and AbstractNumberField have setAutoselect, but several others, like DatePicker, TimePicker and ComboBox only have the client-side attribute

Expected outcome

All client-side components with "autoselect" should have a server-side setAutoselect

Also, there should be an HasAutoselect interface that all should implement (like HasAutocomplete, HasAutocapitalize, etc) so that I can loop over my components and do if(component instanceof HasAutoSelect) { ((HasAutoSelect)component).setAutoSelect(true); }

Minimal reproducible example

// This compiles:
TextField textField = new TextField("TextField");
textField.setAutoselect(true);

IntegerField integerField = new IntegerField("IntegerField");
integerField.setAutoselect(true);

// This should work, but doesn't compile
DatePicker datePicker = new DatePicker("DatePicker");
datePicker.setAutoselect(true);

// This workaround works, so the client-side support is there
datePicker.getElement().setAttribute("autoselect", "true");

Steps to reproduce

N/A

Environment

Vaadin - 23.1.0

Browsers

Issue is not browser related

web-padawan commented 2 years ago

See also #1109 and #1110. It would make sense to create a new common interface and use it in DatePicker / TimePicker.