Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

UI updates: Fix for attribute input not responding to language change (#1302)

Martin Peetersafcabfb16924
diff --git a/ui/component/or-asset-viewer/src/index.ts b/ui/component/or-asset-viewer/src/index.ts
index eb6544c98..961355111 100644
--- a/ui/component/or-asset-viewer/src/index.ts
+++ b/ui/component/or-asset-viewer/src/index.ts
@@ -1147,6 +1147,17 @@ export class OrAssetViewer extends subscribe(manager)(translate(i18next)(LitElem
return !!this.editMode && this._assetInfo && this._assetInfo.modified;
}
+ /**
+ * When language is changed, we clear the cached templates,
+ * so can be rendered differently according to the selected language.
+ */
+ langChangedCallback = () => {
+ if(this._assetInfo) {
+ this._assetInfo.attributeTemplateMap = {};
+ this.requestUpdate("_assetInfo");
+ }
+ }
+
shouldUpdate(changedProperties: PropertyValues): boolean {
if (this._isReadonly()) {
diff --git a/ui/component/or-attribute-input/src/index.ts b/ui/component/or-attribute-input/src/index.ts
index 0342c53ee..c5e2ada27 100644
--- a/ui/component/or-attribute-input/src/index.ts
+++ b/ui/component/or-attribute-input/src/index.ts
@@ -441,6 +441,11 @@ export class OrAttributeInput extends subscribe(manager)(translate(i18next)(LitE
this._clearWriteTimeout();
}
+ langChangedCallback = () => {
+ this._updateTemplate();
+ this.requestUpdate();
+ }
+
public shouldUpdate(_changedProperties: PropertyValues): boolean {
const shouldUpdate = super.shouldUpdate(_changedProperties);
diff --git a/ui/component/or-mwc-components/src/or-mwc-input.ts b/ui/component/or-mwc-components/src/or-mwc-input.ts
index e2e04496d..afef6114e 100644
--- a/ui/component/or-mwc-components/src/or-mwc-input.ts
+++ b/ui/component/or-mwc-components/src/or-mwc-input.ts
@@ -1660,6 +1660,10 @@ export class OrMwcInput extends LitElement {
}
}
+ if(_changedProperties.has("label")) {
+ (this._mdcComponent as any)?.layout?.(); // Adjusts the dimensions and positions for all sub-elements.
+ }
+
if (this.autoValidate) {
this.reportValidity();
}