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 b1e3d40
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
}

@Override
protected <L extends Serializable> Component newLabel(String markupId, IModel<L> model) {
Component label = super.newLabel(markupId, model);
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 b1e3d40

Please sign in to comment.