mirror of
https://github.com/home-assistant/frontend.git
synced 2025-05-03 09:38:43 +00:00
Allow to input decimal in ha-form-float (#10575)
This commit is contained in:
parent
0e8a06e24d
commit
67d79d618a
@ -47,12 +47,19 @@ export class HaFormFloat extends LitElement implements HaFormElement {
|
|||||||
|
|
||||||
private _valueChanged(ev: Event) {
|
private _valueChanged(ev: Event) {
|
||||||
const source = ev.target as TextField;
|
const source = ev.target as TextField;
|
||||||
const rawValue = source.value;
|
const rawValue = source.value.replace(",", ".");
|
||||||
|
|
||||||
let value: number | undefined;
|
let value: number | undefined;
|
||||||
|
|
||||||
|
if (rawValue.endsWith(".")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (rawValue !== "") {
|
if (rawValue !== "") {
|
||||||
value = parseFloat(rawValue);
|
value = parseFloat(rawValue);
|
||||||
|
if (isNaN(value)) {
|
||||||
|
value = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Detect anything changed
|
// Detect anything changed
|
||||||
@ -61,7 +68,6 @@ export class HaFormFloat extends LitElement implements HaFormElement {
|
|||||||
const newRawValue = value === undefined ? "" : String(value);
|
const newRawValue = value === undefined ? "" : String(value);
|
||||||
if (source.value !== newRawValue) {
|
if (source.value !== newRawValue) {
|
||||||
source.value = newRawValue;
|
source.value = newRawValue;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
|||||||
);
|
);
|
||||||
const lastDate = this._lastLogbookDate || hoursToShowDate;
|
const lastDate = this._lastLogbookDate || hoursToShowDate;
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
let newEntries;
|
let newEntries: LogbookEntry[];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
[newEntries] = await Promise.all([
|
[newEntries] = await Promise.all([
|
||||||
@ -256,6 +256,7 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
|||||||
]);
|
]);
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
this._error = err.message;
|
this._error = err.message;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const logbookEntries = this._logbookEntries
|
const logbookEntries = this._logbookEntries
|
||||||
|
Loading…
x
Reference in New Issue
Block a user