mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-18 07:56:44 +01:00
ha-authorize fix rtl check (#29937)
Add RTL direction handling in updated lifecycle method
This commit is contained in:
@@ -2,10 +2,10 @@ import type { LitElement, PropertyValues } from "lit";
|
|||||||
import { property, state } from "lit/decorators";
|
import { property, state } from "lit/decorators";
|
||||||
import type { LocalizeFunc } from "../common/translations/localize";
|
import type { LocalizeFunc } from "../common/translations/localize";
|
||||||
import { computeLocalize } from "../common/translations/localize";
|
import { computeLocalize } from "../common/translations/localize";
|
||||||
|
import { computeDirectionStyles } from "../common/util/compute_rtl";
|
||||||
|
import { translationMetadata } from "../resources/translations-metadata";
|
||||||
import type { Constructor, Resources } from "../types";
|
import type { Constructor, Resources } from "../types";
|
||||||
import { getLocalLanguage, getTranslation } from "../util/common-translation";
|
import { getLocalLanguage, getTranslation } from "../util/common-translation";
|
||||||
import { translationMetadata } from "../resources/translations-metadata";
|
|
||||||
import { computeDirectionStyles } from "../common/util/compute_rtl";
|
|
||||||
|
|
||||||
const empty = () => "";
|
const empty = () => "";
|
||||||
|
|
||||||
@@ -28,16 +28,16 @@ export const litLocalizeLiteMixin = <T extends Constructor<LitElement>>(
|
|||||||
this._initializeLocalizeLite();
|
this._initializeLocalizeLite();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected firstUpdated(changedProps: PropertyValues) {
|
|
||||||
super.firstUpdated(changedProps);
|
|
||||||
computeDirectionStyles(
|
|
||||||
translationMetadata.translations[this.language!].isRTL,
|
|
||||||
this
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected willUpdate(changedProperties: PropertyValues) {
|
protected willUpdate(changedProperties: PropertyValues) {
|
||||||
super.willUpdate(changedProperties);
|
super.willUpdate(changedProperties);
|
||||||
|
|
||||||
|
if (!this.updated || changedProperties.has("language")) {
|
||||||
|
computeDirectionStyles(
|
||||||
|
translationMetadata.translations[this.language!].isRTL,
|
||||||
|
this
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (changedProperties.get("language")) {
|
if (changedProperties.get("language")) {
|
||||||
this._resources = undefined;
|
this._resources = undefined;
|
||||||
this._initializeLocalizeLite();
|
this._initializeLocalizeLite();
|
||||||
|
|||||||
Reference in New Issue
Block a user