flow-components
flow-components copied to clipboard
[formlayout] invalid property is not properly reflected from the component
Description
Given a component with required indicator set to true in a form layout with label.
If the invalid state is set to false in during the value change event of the component, and the value is set to empty, the required indicator of the form item label will turn red because of the invalid state. This is not consistent with the behavior of the label of a input without form item.
Expected outcome
The invalid state should be in sync with the invalid state of the component
Minimal reproducible example
var requiredTextField = new TextField("label");
requiredTextField.setRequiredIndicatorVisible(true);
requiredTextField.addValueChangeListener(e -> requiredTextField.setInvalid(false));
var formLayout = new FormLayout();
formLayout.addFormItem(requiredTextField, "Form item label");
Steps to reproduce
Sets the value to an non empty value and change back to empty value. -> the required indicator of the TextField is not red -> the required indicator of the FormItem label IS red
Environment
Vaadin version(s): 24.5.14
Browsers
No response