mirror of
https://github.com/home-assistant/frontend.git
synced 2025-11-13 04:50:29 +00:00
Minor UI bugfixes for selector-datetime and dialog-date-picker (#15759)
Co-authored-by: Bram Kragten <mail@bramkragten.nl>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import "@material/mwc-button/mwc-button";
|
||||
import "app-datepicker";
|
||||
import { format } from "date-fns";
|
||||
import { css, html, LitElement, nothing } from "lit";
|
||||
import { customElement, property, state } from "lit/decorators";
|
||||
import { fireEvent } from "../common/dom/fire_event";
|
||||
@@ -66,11 +67,16 @@ export class HaDialogDatePicker extends LitElement {
|
||||
}
|
||||
|
||||
private _setToday() {
|
||||
// en-CA locale used for date format YYYY-MM-DD
|
||||
this._value = new Date().toLocaleDateString("en-CA");
|
||||
const today = new Date();
|
||||
this._value = format(today, "yyyy-MM-dd");
|
||||
}
|
||||
|
||||
private _setValue() {
|
||||
if (!this._value) {
|
||||
// Date picker opens to today if value is undefined. If user click OK
|
||||
// without changing the date, should return todays date, not undefined.
|
||||
this._setToday();
|
||||
}
|
||||
this._params?.onChange(this._value!);
|
||||
this.closeDialog();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user