Skip to content

Commit

Permalink
Only add class .sr-only when the label is empty - check in onConfigure
Browse files Browse the repository at this point in the history
  • Loading branch information
vrozkovec committed Dec 3, 2023
1 parent 048e4a7 commit 0a52cd8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,15 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
@Override
protected <L extends Serializable> Component newLabel(String markupId, IModel<L> model) {
Component label = super.newLabel(markupId, model);
return label;
}

@Override
protected void onConfigure() {
super.onConfigure();
Component label = get("label");
if (Strings.isEmpty(label.getDefaultModelObjectAsString())) {
label.add(AttributeModifier.append("class", "sr-only"));
label.add(AttributeModifier.append("class", "sr-only"));
}
return label;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,15 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
protected <L extends Serializable> Component newLabel(String markupId, IModel<L> model) {
Component label = super.newLabel(markupId, model);
label.setRenderBodyOnly(false);
return label;
}

@Override
protected void onConfigure() {
super.onConfigure();
Component label = get("label");
if (Strings.isEmpty(label.getDefaultModelObjectAsString())) {
label.add(AttributeModifier.append("class", "sr-only"));
label.add(AttributeModifier.append("class", "sr-only"));
}
return label;
}
}

0 comments on commit 0a52cd8

Please sign in to comment.