From d2cea159af9d7e7e48ea92d2071c6f9689be1635 Mon Sep 17 00:00:00 2001 From: Bram Kragten Date: Mon, 1 Sep 2025 14:09:13 +0200 Subject: [PATCH] Enable drag and drop on mobile for automations (#26805) --- .../automation/action/ha-automation-action.ts | 22 ++----------------- .../condition/ha-automation-condition.ts | 22 ++----------------- .../automation/option/ha-automation-option.ts | 22 ++----------------- .../dialog-paste-replace.ts | 11 +++++----- .../trigger/ha-automation-trigger.ts | 22 ++----------------- 5 files changed, 14 insertions(+), 85 deletions(-) diff --git a/src/panels/config/automation/action/ha-automation-action.ts b/src/panels/config/automation/action/ha-automation-action.ts index 67270fd89a..f23cfaf414 100644 --- a/src/panels/config/automation/action/ha-automation-action.ts +++ b/src/panels/config/automation/action/ha-automation-action.ts @@ -6,7 +6,6 @@ import { customElement, property, queryAll, state } from "lit/decorators"; import { repeat } from "lit/directives/repeat"; import { storage } from "../../../../common/decorators/storage"; import { fireEvent } from "../../../../common/dom/fire_event"; -import { listenMediaQuery } from "../../../../common/dom/media_query"; import { nextRender } from "../../../../common/util/render-status"; import "../../../../components/ha-button"; import "../../../../components/ha-sortable"; @@ -46,8 +45,6 @@ export default class HaAutomationAction extends LitElement { @property({ type: Boolean, attribute: "sidebar" }) public optionsInSidebar = false; - @state() private _showReorder = false; - @state() private _rowSortSelected?: number; @state() @@ -68,27 +65,12 @@ export default class HaAutomationAction extends LitElement { private _actionKeys = new WeakMap(); - private _unsubMql?: () => void; - - public connectedCallback() { - super.connectedCallback(); - this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => { - this._showReorder = matches; - }); - } - - public disconnectedCallback() { - super.disconnectedCallback(); - this._unsubMql?.(); - this._unsubMql = undefined; - } - protected render() { return html` - ${this._showReorder && !this.disabled + ${!this.disabled ? html`
(); - private _unsubMql?: () => void; - - public connectedCallback() { - super.connectedCallback(); - this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => { - this._showReorder = matches; - }); - } - - public disconnectedCallback() { - super.disconnectedCallback(); - this._unsubMql?.(); - this._unsubMql = undefined; - } - protected updated(changedProperties: PropertyValues) { if (!changedProperties.has("conditions")) { return; @@ -165,7 +147,7 @@ export default class HaAutomationCondition extends LitElement { - ${this._showReorder && !this.disabled + ${!this.disabled ? html`
(); - private _unsubMql?: () => void; - - public connectedCallback() { - super.connectedCallback(); - this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => { - this._showReorder = matches; - }); - } - - public disconnectedCallback() { - super.disconnectedCallback(); - this._unsubMql?.(); - this._unsubMql = undefined; - } - protected render() { return html` - ${this._showReorder && !this.disabled + ${!this.disabled ? html`
(); - private _unsubMql?: () => void; - - public connectedCallback() { - super.connectedCallback(); - this._unsubMql = listenMediaQuery("(min-width: 600px)", (matches) => { - this._showReorder = matches; - }); - } - - public disconnectedCallback() { - super.disconnectedCallback(); - this._unsubMql?.(); - this._unsubMql = undefined; - } - protected render() { return html` - ${this._showReorder && !this.disabled + ${!this.disabled ? html`