Fix button and gallery action handler

This commit is contained in:
Wendelin 2025-05-26 17:43:37 +02:00
parent 97a91e48e3
commit f9620c2e89
No known key found for this signature in database
2 changed files with 12 additions and 5 deletions

View File

@ -1,8 +1,8 @@
import type { TemplateResult } from "lit";
import { css, html, LitElement } from "lit";
import { customElement } from "lit/decorators";
import "../../../../src/components/ha-card";
import "../../../../src/components/ha-button";
import "../../../../src/components/ha-card";
import type { ActionHandlerEvent } from "../../../../src/data/lovelace/action_handler";
import { actionHandler } from "../../../../src/panels/lovelace/common/directives/action-handler-directive";
@ -16,7 +16,10 @@ export class DemoUtilLongPress extends LitElement {
<ha-button
appearance="plain"
@action=${this._handleAction}
.actionHandler=${actionHandler({})}
.actionHandler=${actionHandler({
hasHold: true,
hasDoubleClick: true,
})}
>
(long) press me!
</ha-button>

View File

@ -1,3 +1,4 @@
import { mdiPlus } from "@mdi/js";
import type { PropertyValues, TemplateResult } from "lit";
import { css, html, LitElement, nothing } from "lit";
import { customElement, property, state } from "lit/decorators";
@ -5,12 +6,14 @@ import memoizeOne from "memoize-one";
import { stopPropagation } from "../../common/dom/stop_propagation";
import type { LocalizeFunc } from "../../common/translations/localize";
import type { HomeAssistant } from "../../types";
import "./ha-form";
import "../ha-button";
import "../ha-list-item";
import "../ha-svg-icon";
import "./ha-form";
import type {
HaFormOptionalActionsSchema,
HaFormDataContainer,
HaFormElement,
HaFormOptionalActionsSchema,
HaFormSchema,
} from "./types";
@ -118,7 +121,8 @@ export class HaFormOptionalActions extends LitElement implements HaFormElement {
fixed
@closed=${stopPropagation}
>
<ha-button slot="trigger">
<ha-button slot="trigger" appearance="filled" size="small">
<ha-svg-icon .path=${mdiPlus} slot="prefix"></ha-svg-icon>
${this.localize?.("ui.components.form-optional-actions.add") ||
"Add interaction"}
</ha-button>