With Vaadin 24.3.12, when I set a checkbox to read-only, it looks exactly as before, doesn’t have readonly=“” attribute in browser and when I click it, it toggles then resets to previous value. I assume it is reset by server.
If I manually insert a readonly=“” attribute in browser nothing changes.
Bug?
If I switch to checkbox.setEnabled(!readOnly) everything works as expected.
@Route(value="/test")
public class Test extends VerticalLayout {
boolean readOnly=false;
boolean enabled=true;
public Test() {
var checkbox = new Checkbox("Checkbox");
var textField = new TextField("TextField");
var toggleReadOnly = new Button("Toggle ReadOnly", event -> {
readOnly = !readOnly;
checkbox.setReadOnly(readOnly);
textField.setReadOnly(readOnly);
});
var toggleEnabled = new Button("Toggle Enabled", event -> {
enabled = !enabled;
checkbox.setEnabled(enabled);
textField.setEnabled(enabled);
});
add(checkbox, textField, toggleReadOnly, toggleEnabled);
}
}