Guttorm
(Guttorm Vik)
March 22, 2024, 2:49pm
1
I’ve added textField.setAutoselect(true) to my app, and that works just fine.
This method is on TextFieldBase, so DatePicker is excluded, which is annoying.
textField.setAutoselect does:
getElement().setProperty(“autoselect”, autoselect);
That works on DatePicker as well…
Looks like DatePicker should’ve inherited from TextFieldBase
You can file a feature request. Maybe there is already one Issues · vaadin/flow-components · GitHub
1 Like
knoobie
(Christian Knoop)
March 22, 2024, 6:10pm
3
Didn’t you create an issue for that already? ;) If it annoys you, the change looks pretty simple - so creating a PR is probably doable
opened 02:51PM - 28 Jun 22 UTC
enhancement
### Description
TextField and AbstractNumberField have setAutoselect, but sever… al 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
Guttorm
(Guttorm Vik)
March 25, 2024, 9:11am
4
2022… I had forgotten about that
When that is said, I have noticed that Vaadin have been picking up older issues lately, so maybe there’s hope.
1 Like
Matti
(Matti Tahvonen)
March 25, 2024, 6:22pm
5
No need to wait, Viritin 2.8.5 (currently syncing to central) contains something better than this “autoselect thingie”, full Selection API, now also for VDatePicker, coming your way
VDatePicker datePicker = new VDatePicker();
datePicker.setValue(LocalDate.now());
add(datePicker,
new Button("Select all in date picker", e -> datePicker.selectAll()),
new Button("Select 0-2", e -> datePicker.setSelectionRange(0, 2))
);
1 Like