-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Minor UI bugfixes for selector-datetime and dialog-date-picker #15759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
const y = today.getFullYear(); | ||
const m = (today.getMonth() + 1 < 10 ? "0" : "") + (today.getMonth() + 1); | ||
const d = (today.getDate() < 10 ? "0" : "") + today.getDate(); | ||
this._value = y + "-" + m + "-" + d; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I contemplated putting this in format_date, but I couldn't think of a good name to give it, and didn't see it used elsewhere. I would have hoped there would be an easier standard way to get this format, but I couldn't find one.
@value-changed=${this._valueChanged} | ||
> | ||
</ha-date-input> | ||
<ha-time-input | ||
enable-second | ||
.value=${values?.[1] || "0:00:00"} | ||
.value=${values?.[1] || "00:00:00"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If pass "0:00:00" to time-input, it reformats it as "00:00:00" and fires an unwanted value-changed event.
@@ -72,7 +72,7 @@ export class HaDateTimeSelector extends LitElement { | |||
|
|||
private _sendChangedEvent(): void { | |||
fireEvent(this, "value-changed", { | |||
value: `${this._dateInput.value} ${this._timeInput.value}`, | |||
value: `${this._dateInput.value ?? ""} ${this._timeInput.value}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we not just only send a change event when we can send a valid value? So when we have both a date and time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes we can do that. Updated.
bcdadb7
to
c7e5399
Compare
Proposed change
A few miscellaneous bugfixes:
The date format for en-CA was recently changed from "yyyy-mm-dd" to "mm/dd/yyyy". This has broken the
today
button on the date picker, which relied on the specific en-CA format. It looks like it may change back in the future, but just change the code to format the date in the correct way as needed, rather than rely on the future politicial whims of Canadians.See ToLocaleDateString inconsistent/wrong output locale to "en-CA" nodejs/node#45945 and https://unicode-org.atlassian.net/browse/CLDR-16399 for more background.
When opening a date-picker-dialog with the value of undefined, it was not possible to select today's date without first clicking to a different date, and then clicking back on today. Fix this behavior.
The datetime selector has some problems, detailed in ha-selector-datetime broken in ha-service-control #15755, which are fixed here.
Type of change
Example configuration
Additional information
Checklist
If user exposed functionality or configuration variables are added/changed: