Skip to content

Commit

Permalink
fix #860 calling setLabel(String label) removes required indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
vegegoku committed Oct 26, 2023
1 parent a1a0fbd commit a34f0eb
Showing 1 changed file with 6 additions and 1 deletion.
Expand Up @@ -20,6 +20,7 @@

import elemental2.dom.HTMLElement;
import elemental2.dom.HTMLFieldSetElement;
import elemental2.dom.Text;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -93,6 +94,8 @@ public abstract class AbstractFormElement<T extends AbstractFormElement<T, V>, V
private boolean focusValidationPaused = false;
private boolean emptyAsNull;

private Text labelText = text();

protected V defaultValue;
private boolean showRequiredIndicator = true;

Expand All @@ -107,6 +110,7 @@ public AbstractFormElement() {
.addCss(dui_field_body)
.appendChild(wrapperElement = div().addCss(dui_input_wrapper)));
labelElement = LazyChild.of(label().addCss(dui_field_label), formElement);
labelElement.whenInitialized(() -> labelElement.element().appendChild(labelText));
messagesWrapper = LazyChild.of(div().addCss(dui_messages_wrapper), bodyElement);
helperTextElement = LazyChild.of(span().addCss(dui_field_helper), messagesWrapper);
errorElementSupplier =
Expand Down Expand Up @@ -375,7 +379,8 @@ public String getHelperText() {
*/
@Override
public T setLabel(String label) {
labelElement.get().setTextContent(label);
labelElement.get();
labelText.textContent = label;
return (T) this;
}

Expand Down

0 comments on commit a34f0eb

Please sign in to comment.