Compare commits

...

2 Commits

Author SHA1 Message Date
Petar Petrov 61c915c7cb Prevent escape from discarding unsaved dashboard editor changes 2026-07-07 08:50:04 +03:00
Yosi Levy 30c44403de Fix RTL in selection in date time picker (#53020) 2026-07-06 16:27:14 +03:00
4 changed files with 29 additions and 13 deletions
@@ -176,7 +176,7 @@ export class DateRangePicker extends MobileAwareMixin(LitElement) {
tabindex="-1"
slot="next"
></ha-icon-button-next>
<calendar-month></calendar-month>
<calendar-month dir=${this.dir}></calendar-month>
</calendar-range>
${
this.timePicker
@@ -26,6 +26,8 @@ import "../ha-icon-button-prev";
import "../ha-textarea";
import type { HaTextArea } from "../ha-textarea";
import "./date-range-picker";
import { computeRTL, emitRTLDirection } from "../../common/util/compute_rtl";
import { translationMetadata } from "../../resources/translations-metadata";
export type DateRangePickerRanges = Record<string, [Date, Date]>;
@@ -239,8 +241,13 @@ export class HaDateRangePicker extends LitElement {
if (!this._opened) {
return nothing;
}
const dir = emitRTLDirection(
computeRTL(this._i18n.locale.language, translationMetadata.translations)
);
return html`
<date-range-picker
dir=${dir}
.ranges=${this.ranges === false ? false : this.ranges || this._ranges}
.startDate=${this.startDate}
.endDate=${this.endDate}
+6 -4
View File
@@ -103,13 +103,15 @@ export const dateRangePickerStyles = css`
}
calendar-month::part(range-start),
calendar-month::part(range-start):hover {
border-top-left-radius: var(--ha-border-radius-circle);
border-bottom-left-radius: var(--ha-border-radius-circle);
/* logical: rounds the inline-start corners (works in LTR and RTL) */
border-start-start-radius: var(--ha-border-radius-circle);
border-end-start-radius: var(--ha-border-radius-circle);
}
calendar-month::part(range-end),
calendar-month::part(range-end):hover {
border-top-right-radius: var(--ha-border-radius-circle);
border-bottom-right-radius: var(--ha-border-radius-circle);
/* logical: rounds the inline-end corners (works in LTR and RTL) */
border-start-end-radius: var(--ha-border-radius-circle);
border-end-end-radius: var(--ha-border-radius-circle);
}
calendar-month::part(range-start):hover,
calendar-month::part(range-end):hover,
+15 -8
View File
@@ -135,8 +135,6 @@ export class HaDialog extends ScrollableFadeMixin(LitElement) {
@state()
private _bodyScrolled = false;
private _escapePressed = false;
public connectedCallback(): void {
super.connectedCallback();
this.addEventListener(
@@ -306,7 +304,6 @@ export class HaDialog extends ScrollableFadeMixin(LitElement) {
private _handleKeyDown(ev: KeyboardEvent) {
if (ev.key === "Escape") {
this._escapePressed = true;
if (this.preventScrimClose) {
ev.preventDefault();
}
@@ -316,13 +313,23 @@ export class HaDialog extends ScrollableFadeMixin(LitElement) {
}
private _handleHide(ev: DialogHideEvent) {
const sourceIsDialog = ev.detail?.source === (ev.target as WaDialog).dialog;
if (this.preventScrimClose && this._escapePressed && sourceIsDialog) {
ev.preventDefault();
// Ignore wa-hide events bubbling up from nested overlays (pickers,
// popovers, bottom sheets, nested dialogs); only handle this dialog's own
// hide, like the sibling wa-* handlers above.
if (ev.eventPhase !== Event.AT_TARGET) {
return;
}
this._escapePressed = false;
const sourceIsDialog = ev.detail?.source === (ev.target as WaDialog).dialog;
// A dialog-sourced hide (Escape, native cancel, or scrim) while the host
// still wants the dialog open is a user dismissal, not a programmatic
// close. Block it when closing must be guarded, regardless of where focus
// currently is — e.g. after a picker overlay took focus and dropped it
// outside the dialog, the Escape keydown never reaches this element.
if (this.preventScrimClose && sourceIsDialog && this.open) {
ev.preventDefault();
}
}
static get styles() {