From f71137331f2fac2ee2b9ee9a6daaf1c639f816ea Mon Sep 17 00:00:00 2001 From: lolodomo Date: Mon, 17 Jul 2023 17:58:01 +0200 Subject: [PATCH] [Sitemap UI] Do not break format defined in label with extra spaces (#3708) Fix openhab/openhab-webui#1953 Fix a regression introduced by PR #3644 Signed-off-by: Laurent Garnier --- .../org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java index 1862082e2e8..8a96b4b9532 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java @@ -515,7 +515,8 @@ private QuantityType convertStateToWidgetUnit(QuantityType quantityState, "Item '{}' with unit, nothing allowed after unit in label pattern '{}', dropping postfix", itemName, pattern); } - pattern = pattern.substring(0, matcherEnd) + (!unit.isBlank() ? " " + unit : ""); + pattern = unit.isBlank() ? pattern.substring(0, matcherEnd) + : pattern.substring(0, pattern.indexOf(unit, matcherEnd) + unit.length()); } } catch (ItemNotFoundException e) { logger.warn("Cannot retrieve item '{}' for widget {}", itemName, w.eClass().getInstanceTypeName());