mirror of
https://github.com/home-assistant/frontend.git
synced 2025-04-26 22:37:21 +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) {
|
||||
const source = ev.target as TextField;
|
||||
const rawValue = source.value;
|
||||
const rawValue = source.value.replace(",", ".");
|
||||
|
||||
let value: number | undefined;
|
||||
|
||||
if (rawValue.endsWith(".")) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rawValue !== "") {
|
||||
value = parseFloat(rawValue);
|
||||
if (isNaN(value)) {
|
||||
value = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// Detect anything changed
|
||||
@ -61,7 +68,6 @@ export class HaFormFloat extends LitElement implements HaFormElement {
|
||||
const newRawValue = value === undefined ? "" : String(value);
|
||||
if (source.value !== newRawValue) {
|
||||
source.value = newRawValue;
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
||||
);
|
||||
const lastDate = this._lastLogbookDate || hoursToShowDate;
|
||||
const now = new Date();
|
||||
let newEntries;
|
||||
let newEntries: LogbookEntry[];
|
||||
|
||||
try {
|
||||
[newEntries] = await Promise.all([
|
||||
@ -256,6 +256,7 @@ export class HuiLogbookCard extends LitElement implements LovelaceCard {
|
||||
]);
|
||||
} catch (err: any) {
|
||||
this._error = err.message;
|
||||
return;
|
||||
}
|
||||
|
||||
const logbookEntries = this._logbookEntries
|
||||
|
Loading…
x
Reference in New Issue
Block a user