-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Rtl menu fix #12561
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rtl menu fix #12561
Changes from 14 commits
20cca1b
5021b6d
949ceda
d8c9684
8ef03cb
f7aa73b
42d0f41
ef9f317
03cbca7
5907d07
60f13eb
d407d9b
c436d5c
cdfadb9
bfcf089
1e50511
53050fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import "@material/mwc-menu"; | |
| import type { Corner, Menu, MenuCorner } from "@material/mwc-menu"; | ||
| import { css, CSSResultGroup, html, LitElement, TemplateResult } from "lit"; | ||
| import { customElement, property, query } from "lit/decorators"; | ||
| import { computeRTL } from "../common/util/compute_rtl"; | ||
|
|
||
| @customElement("ha-button-menu") | ||
| export class HaButtonMenu extends LitElement { | ||
|
|
@@ -50,6 +51,22 @@ export class HaButtonMenu extends LitElement { | |
| `; | ||
| } | ||
|
|
||
| protected firstUpdated(changedProps): void { | ||
| super.firstUpdated(changedProps); | ||
|
|
||
| // @ts-ignore | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we need to ignore this?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left over from previous code. Removing. |
||
| if (document.dir === "rtl") { | ||
| this.updateComplete.then(() => { | ||
| this.querySelectorAll("mwc-list-item").forEach((item) => { | ||
| const style = document.createElement("style"); | ||
| style.innerHTML = | ||
| "span.material-icons:first-of-type { margin-left: var(--mdc-list-item-graphic-margin, 32px) !important; margin-right: 0px !important;}"; | ||
| item!.shadowRoot!.appendChild(style); | ||
| }); | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| private _handleClick(): void { | ||
| if (this.disabled) { | ||
| return; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| import { atLeastVersion } from "../common/config/version"; | ||
| import { computeLocalize, LocalizeFunc } from "../common/translations/localize"; | ||
| import { computeRTL } from "../common/util/compute_rtl"; | ||
| import { computeRTLDirection } from "../common/util/compute_rtl"; | ||
| import { debounce } from "../common/util/debounce"; | ||
| import { | ||
| getHassTranslations, | ||
|
|
@@ -180,7 +180,7 @@ export default <T extends Constructor<HassBaseEl>>(superClass: T) => | |
|
|
||
| private _applyTranslations(hass: HomeAssistant) { | ||
| document.querySelector("html")!.setAttribute("lang", hass.language); | ||
| this.style.direction = computeRTL(hass) ? "rtl" : "ltr"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't need/use this somewhere now?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No. I tested it and it works fine when direction is on body and not on home-assistant tag. All my previous fixes will work because host-context would just climb 1 level up. |
||
| document.dir = computeRTLDirection(hass); | ||
| this._loadCoreTranslations(hass.language); | ||
| this.__loadedFragmetTranslations = new Set(); | ||
| this._loadFragmentTranslations(hass.language, hass.panelUrl); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.