From 0a52cd8cba30e916dcd0cd5417a896306920ba3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADt=20Rozkovec?= Date: Mon, 4 Dec 2023 00:02:40 +0100 Subject: [PATCH] Only add class .sr-only when the label is empty - check in onConfigure --- .../html/bootstrap/spinner/SpinnerAjaxButton.java | 10 ++++++++-- .../markup/html/bootstrap/spinner/SpinnerAjaxLink.java | 10 ++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxButton.java b/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxButton.java index 887d6299e..4c7fc8ccc 100644 --- a/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxButton.java +++ b/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxButton.java @@ -105,9 +105,15 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { @Override protected Component newLabel(String markupId, IModel 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; } } diff --git a/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxLink.java b/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxLink.java index b95410ff8..9f43409f0 100644 --- a/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxLink.java +++ b/bootstrap-extensions/src/main/java/de/agilecoders/wicket/extensions/markup/html/bootstrap/spinner/SpinnerAjaxLink.java @@ -94,9 +94,15 @@ protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { protected Component newLabel(String markupId, IModel 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; } }