Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ComboBox] Validation does not check pattern #6635

Open
vursen opened this issue Sep 12, 2024 · 2 comments
Open

[ComboBox] Validation does not check pattern #6635

vursen opened this issue Sep 12, 2024 · 2 comments

Comments

@vursen
Copy link
Contributor

vursen commented Sep 12, 2024

Description

Although setPattern is available in ComboBox, it only sets the related attribute and doesn't affect validation. This contrasts with the web component where the pattern is actually checked during validation. Without validation, the purpose of the pattern is unclear.

Expected outcome

ComboBox should invalidate if the custom value doesn't match the pattern, same as it works in the web component.

Minimal reproducible example

ComboBox<String> comboBox = new ComboBox<>();
comboBox.setPattern("^\\d+$");
comboBox.setAllowCustomValue(true);

Environment

Vaadin version(s): 24.5 and earlier
OS: Mac OS

Browsers

No response

@vursen vursen changed the title [ComboBox] Validation does not take into account pattern [ComboBox] Validation does not check pattern Sep 12, 2024
@vursen
Copy link
Contributor Author

vursen commented Sep 18, 2024

After discussing this issue, we reached a consensus that pattern makes too little sense for both ComboBox and MultiSelectComboBox. While these fields resemble classic text fields, they are different because their values are typically beans rather than strings. This means that pattern can only validate the string representation of these values, which seems to be rather niche and not worth being supported out of the box. Therefore, our decision is to deprecate the pattern constraint in these components in both their versions: WC and Flow.

@web-padawan
Copy link
Member

Based on the git history, the pattern property was initially just propagated to the underlying vaadin-text-field since vaadin/vaadin-combo-box#557. Before switching to vaadin-text-field, the iron-input and allowedPattern was used (which worked like our allowedCharPattern, which is now supported by all input controls including vaadin-combo-box).

BTW the vaadin-multi-select-combo-box doesn't even use pattern property and I think it doesn't need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants