mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-25 18:26:35 +00:00
Fix language picker in profile displaying wrong language (#17725)
* fix language picker when changing language sort order #16642 * alternative fix
This commit is contained in:
parent
916a6df39b
commit
166acee1c6
@ -41,7 +41,18 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
|
|
||||||
protected updated(changedProperties: PropertyValues) {
|
protected updated(changedProperties: PropertyValues) {
|
||||||
super.updated(changedProperties);
|
super.updated(changedProperties);
|
||||||
if (changedProperties.has("languages") || changedProperties.has("value")) {
|
|
||||||
|
const localeChanged =
|
||||||
|
changedProperties.has("hass") &&
|
||||||
|
this.hass &&
|
||||||
|
changedProperties.get("hass") &&
|
||||||
|
changedProperties.get("hass").locale.language !==
|
||||||
|
this.hass.locale.language;
|
||||||
|
if (
|
||||||
|
changedProperties.has("languages") ||
|
||||||
|
changedProperties.has("value") ||
|
||||||
|
localeChanged
|
||||||
|
) {
|
||||||
this._select.layoutOptions();
|
this._select.layoutOptions();
|
||||||
if (this._select.value !== this.value) {
|
if (this._select.value !== this.value) {
|
||||||
fireEvent(this, "value-changed", { value: this._select.value });
|
fireEvent(this, "value-changed", { value: this._select.value });
|
||||||
@ -54,12 +65,15 @@ export class HaLanguagePicker extends LitElement {
|
|||||||
this.hass.locale,
|
this.hass.locale,
|
||||||
this.nativeName
|
this.nativeName
|
||||||
);
|
);
|
||||||
const selectedItem = languageOptions.find(
|
const selectedItemIndex = languageOptions.findIndex(
|
||||||
(option) => option.value === this.value
|
(option) => option.value === this.value
|
||||||
);
|
);
|
||||||
if (!selectedItem) {
|
if (selectedItemIndex === -1) {
|
||||||
this.value = undefined;
|
this.value = undefined;
|
||||||
}
|
}
|
||||||
|
if (localeChanged) {
|
||||||
|
this._select.select(selectedItemIndex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user