mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-14 12:56:37 +00:00
Fix Suggested Value in HA-Form (#13173)
This commit is contained in:
parent
55e9ebc4d2
commit
be52ba0ea9
@ -6,7 +6,7 @@ export const computeInitialHaFormData = (
|
|||||||
): Record<string, any> => {
|
): Record<string, any> => {
|
||||||
const data = {};
|
const data = {};
|
||||||
schema.forEach((field) => {
|
schema.forEach((field) => {
|
||||||
if (field.description?.suggested_value) {
|
if (field.description?.suggested_value !== undefined) {
|
||||||
data[field.name] = field.description.suggested_value;
|
data[field.name] = field.description.suggested_value;
|
||||||
} else if ("default" in field) {
|
} else if ("default" in field) {
|
||||||
data[field.name] = field.default;
|
data[field.name] = field.default;
|
||||||
|
@ -3,15 +3,15 @@ import {
|
|||||||
CSSResultGroup,
|
CSSResultGroup,
|
||||||
html,
|
html,
|
||||||
LitElement,
|
LitElement,
|
||||||
TemplateResult,
|
|
||||||
PropertyValues,
|
PropertyValues,
|
||||||
|
TemplateResult,
|
||||||
} from "lit";
|
} from "lit";
|
||||||
import { customElement, property, query } from "lit/decorators";
|
import { customElement, property, query } from "lit/decorators";
|
||||||
import { fireEvent } from "../../common/dom/fire_event";
|
import { fireEvent } from "../../common/dom/fire_event";
|
||||||
import { HaCheckbox } from "../ha-checkbox";
|
import { HaCheckbox } from "../ha-checkbox";
|
||||||
import { HaFormElement, HaFormIntegerData, HaFormIntegerSchema } from "./types";
|
|
||||||
import "../ha-slider";
|
import "../ha-slider";
|
||||||
import { HaTextField } from "../ha-textfield";
|
import { HaTextField } from "../ha-textfield";
|
||||||
|
import { HaFormElement, HaFormIntegerData, HaFormIntegerSchema } from "./types";
|
||||||
|
|
||||||
@customElement("ha-form-integer")
|
@customElement("ha-form-integer")
|
||||||
export class HaFormInteger extends LitElement implements HaFormElement {
|
export class HaFormInteger extends LitElement implements HaFormElement {
|
||||||
@ -105,7 +105,7 @@ export class HaFormInteger extends LitElement implements HaFormElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.schema.description?.suggested_value ||
|
this.schema.description?.suggested_value !== undefined ||
|
||||||
this.schema.default ||
|
this.schema.default ||
|
||||||
this.schema.valueMin ||
|
this.schema.valueMin ||
|
||||||
0
|
0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user