mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-27 11:16:35 +00:00
Fix invalid style in password manager polyfill and ha-bar (#15603)
This commit is contained in:
parent
7568ae5964
commit
ba3b265b9a
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable lit/prefer-static-styles */
|
import { css, html, LitElement, nothing } from "lit";
|
||||||
import { html, LitElement, TemplateResult } from "lit";
|
|
||||||
import { customElement, property } from "lit/decorators";
|
import { customElement, property } from "lit/decorators";
|
||||||
|
import { styleMap } from "lit/directives/style-map";
|
||||||
import { fireEvent } from "../common/dom/fire_event";
|
import { fireEvent } from "../common/dom/fire_event";
|
||||||
import type { HaFormSchema } from "../components/ha-form/types";
|
import type { HaFormSchema } from "../components/ha-form/types";
|
||||||
import { autocompleteLoginFields } from "../data/auth";
|
import { autocompleteLoginFields } from "../data/auth";
|
||||||
@ -29,18 +29,14 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
|
|
||||||
@property({ attribute: false }) public boundingRect?: DOMRect;
|
@property({ attribute: false }) public boundingRect?: DOMRect;
|
||||||
|
|
||||||
protected createRenderRoot() {
|
private _styleElement?: HTMLStyleElement;
|
||||||
// Add under document body so the element isn't placed inside any shadow roots
|
|
||||||
return document.body;
|
|
||||||
}
|
|
||||||
|
|
||||||
private get styles() {
|
public connectedCallback() {
|
||||||
return `
|
super.connectedCallback();
|
||||||
|
this._styleElement = document.createElement("style");
|
||||||
|
this._styleElement.textContent = css`
|
||||||
.password-manager-polyfill {
|
.password-manager-polyfill {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: ${this.boundingRect?.y || 148}px;
|
|
||||||
left: calc(50% - ${(this.boundingRect?.width || 360) / 2}px);
|
|
||||||
width: ${this.boundingRect?.width || 360}px;
|
|
||||||
opacity: 0;
|
opacity: 0;
|
||||||
z-index: -1;
|
z-index: -1;
|
||||||
}
|
}
|
||||||
@ -54,10 +50,22 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
width: 0;
|
width: 0;
|
||||||
height: 0;
|
height: 0;
|
||||||
}
|
}
|
||||||
`;
|
`.toString();
|
||||||
|
document.head.append(this._styleElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected render(): TemplateResult {
|
public disconnectedCallback() {
|
||||||
|
super.disconnectedCallback();
|
||||||
|
this._styleElement?.remove();
|
||||||
|
delete this._styleElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected createRenderRoot() {
|
||||||
|
// Add under document body so the element isn't placed inside any shadow roots
|
||||||
|
return document.body;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected render() {
|
||||||
if (
|
if (
|
||||||
this.step &&
|
this.step &&
|
||||||
this.step.type === "form" &&
|
this.step.type === "form" &&
|
||||||
@ -67,6 +75,11 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
return html`
|
return html`
|
||||||
<form
|
<form
|
||||||
class="password-manager-polyfill"
|
class="password-manager-polyfill"
|
||||||
|
style=${styleMap({
|
||||||
|
top: `${this.boundingRect?.y || 148}px`,
|
||||||
|
left: `calc(50% - ${(this.boundingRect?.width || 360) / 2}px)`,
|
||||||
|
width: `${this.boundingRect?.width || 360}px`,
|
||||||
|
})}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
@submit=${this._handleSubmit}
|
@submit=${this._handleSubmit}
|
||||||
>
|
>
|
||||||
@ -74,16 +87,13 @@ export class HaPasswordManagerPolyfill extends LitElement {
|
|||||||
this.render_input(input)
|
this.render_input(input)
|
||||||
)}
|
)}
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
<style>
|
|
||||||
${this.styles}
|
|
||||||
</style>
|
|
||||||
</form>
|
</form>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
return html``;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
private render_input(schema: HaFormSchema): TemplateResult | string {
|
private render_input(schema: HaFormSchema) {
|
||||||
const inputType = schema.name.includes("password") ? "password" : "text";
|
const inputType = schema.name.includes("password") ? "password" : "text";
|
||||||
if (schema.type !== "string") {
|
if (schema.type !== "string") {
|
||||||
return "";
|
return "";
|
||||||
|
@ -44,7 +44,6 @@ export class HaBar extends LitElement {
|
|||||||
}
|
}
|
||||||
rect:last-child {
|
rect:last-child {
|
||||||
fill: var(--ha-bar-primary-color, var(--primary-color));
|
fill: var(--ha-bar-primary-color, var(--primary-color));
|
||||||
rx: var(--ha-bar-border-radius, 4px);
|
|
||||||
}
|
}
|
||||||
svg {
|
svg {
|
||||||
border-radius: var(--ha-bar-border-radius, 4px);
|
border-radius: var(--ha-bar-border-radius, 4px);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user