AutoSelectComboBox
ComboBox with autoselect and validation
Description
If there is only one match while typing a custom value in combobox, it selects the matched value in blur when either the user hit ENTER or leave focus from the field (clicking any other area outside of combobox).
The default behaviour of combobox is that when leaving the focus, it clears the value however with AutoSelectComboBox the value stay as it is and it can show a custom error massage if there is no exactly one match with the input.
Compatibility
- Version 1.x.x -> Vaadin 14+
- Version 2.x.x -> Vaadin 23.1.x
- Version 3.x.x -> Vaadin 23.2.x
Sample code
AutoSelectComboBox<Person> asComboBox = new AutoSelectComboBox<>("Another People"); asComboBox.setHelperText("Custom Web Component. Auto select if 1 option. Allow custom values + run validation against options."); asComboBox.setDataProvider(dataProvider); asComboBox.setItemLabelGenerator(Person::toString); Binder<TestBean> binder = new Binder<>(); binder.forField(comboBox) .asRequired(Validator.from(personService::exists, "Please select one of the available values")) .bind(TestBean::getPerson, TestBean::setPerson); TestBean item = new TestBean(); binder.setBean(item);
Links
Compatibility
Was this helpful? Need more help?
Leave a comment or a question below. You can also join
the chat on Discord or
ask questions on StackOverflow.
Version
Update to Vaadin 23.4.0 and Vaadin 24
- Released
- 2024-03-12
- Maturity
- EXPERIMENTAL
- License
- Apache License 2.0
Compatibility
- Framework
- Vaadin 23
- Vaadin 24
- Vaadin 14 in 1.0.5
- Browser
- N/A
AutoSelectComboBox - Vaadin Add-on Directory
ComboBox with autoselect and validationOnline Demo
AutoSelectComboBox version 1.0.0
This is the first version release
AutoSelectComboBox version 1.0.1
web version of the component (vcf-auto-select-combobox) created so js file is extracted as npm package
AutoSelectComboBox version 1.0.2
structure improvement
AutoSelectComboBox version 1.0.3
vaadin to vaadin-core update
AutoSelectComboBox version 1.0.4
tag name update
AutoSelectComboBox version 1.0.5
name change update
AutoSelectComboBox version 2.0.0
Version compatible with Vaadin 23.1.2.
AutoSelectComboBox version 3.0.0
Update to make component compatible with Vaadin 23.2.
AutoSelectComboBox version 3.0.1
Fixes issue where selection was cleared after blur when there is only one item in the dataset
AutoSelectComboBox version 3.0.2
Upgraded to use the web component version of vcf-auto-select-combobox 17.0.0, where the component now doesn't clear invalid input
AutoSelectComboBox version 3.0.3
Updated to web component version 17.0.1. Clearing the input with a single-item list should now work as expected.
AutoSelectComboBox version 3.1.0
Update to Vaadin 23.4.0 and Vaadin 24