Skip to content

Commit 1e1514e

Browse files
authored
forwardHaptic on node rather than window. (#27251)
forwardHaptic on node rather than window. Allows for capturing for custom cards.
1 parent 60e0707 commit 1e1514e

21 files changed

+32
-32
lines changed

src/components/entity/ha-entity-toggle.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ export class HaEntityToggle extends LitElement {
112112
if (!this.hass || !this.stateObj) {
113113
return;
114114
}
115-
forwardHaptic("light");
115+
forwardHaptic(this, "light");
116116
const stateDomain = computeStateDomain(this.stateObj);
117117
let serviceDomain;
118118
let service;

src/components/ha-switch.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class HaSwitch extends SwitchBase {
1515
super.firstUpdated();
1616
this.addEventListener("change", () => {
1717
if (this.haptic) {
18-
forwardHaptic("light");
18+
forwardHaptic(this, "light");
1919
}
2020
});
2121
}

src/data/haptics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@ declare global {
2828
}
2929
}
3030

31-
export const forwardHaptic = (hapticType: HapticType) => {
32-
fireEvent(window, "haptic", hapticType);
31+
export const forwardHaptic = (node: HTMLElement, hapticType: HapticType) => {
32+
fireEvent(node, "haptic", hapticType);
3333
};

src/dialogs/more-info/controls/more-info-fan.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MoreInfoFan extends LitElement {
4242

4343
private _toggle = () => {
4444
const service = this.stateObj?.state === "on" ? "turn_off" : "turn_on";
45-
forwardHaptic("light");
45+
forwardHaptic(this, "light");
4646
this.hass.callService("fan", service, {
4747
entity_id: this.stateObj!.entity_id,
4848
});

src/dialogs/more-info/controls/more-info-light.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class MoreInfoLight extends LitElement {
310310
311311
private _toggle = () => {
312312
const service = this.stateObj?.state === "on" ? "turn_off" : "turn_on";
313-
forwardHaptic("light");
313+
forwardHaptic(this, "light");
314314
this.hass.callService("light", service, {
315315
entity_id: this.stateObj!.entity_id,
316316
});

src/panels/config/integrations/integration-panels/zha/zha-cluster-attributes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,10 @@ export class ZHAClusterAttributes extends LitElement {
210210
this._readingAttribute = true;
211211
try {
212212
this._attributeValue = await readAttributeValue(this.hass, data);
213-
forwardHaptic("success");
213+
forwardHaptic(this, "success");
214214
button.actionSuccess();
215215
} catch (_err: any) {
216-
forwardHaptic("failure");
216+
forwardHaptic(this, "failure");
217217
button.actionError();
218218
} finally {
219219
this._readingAttribute = false;

src/panels/config/scene/ha-scene-dashboard.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1087,7 +1087,7 @@ ${rejected
10871087
name: computeStateName(scene),
10881088
}),
10891089
});
1090-
forwardHaptic("light");
1090+
forwardHaptic(this, "light");
10911091
};
10921092

10931093
private _deleteConfirm(scene: SceneEntity): void {

src/panels/developer-tools/action/developer-tools-action.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ class HaPanelDevAction extends LitElement {
443443
const button = ev.currentTarget as HaProgressButton;
444444

445445
if (this._yamlMode && !this._yamlValid) {
446-
forwardHaptic("failure");
446+
forwardHaptic(this, "failure");
447447
button.actionError();
448448
this._error = this.hass.localize(
449449
"ui.panel.developer-tools.tabs.actions.errors.yaml.invalid_yaml"
@@ -465,7 +465,7 @@ class HaPanelDevAction extends LitElement {
465465
);
466466

467467
if (this._error !== undefined) {
468-
forwardHaptic("failure");
468+
forwardHaptic(this, "failure");
469469
button.actionError();
470470
return;
471471
}
@@ -534,7 +534,7 @@ class HaPanelDevAction extends LitElement {
534534
) {
535535
return;
536536
}
537-
forwardHaptic("failure");
537+
forwardHaptic(this, "failure");
538538
button.actionError();
539539

540540
let localizedErrorMessage: string | undefined;

src/panels/lovelace/card-features/hui-area-controls-card-feature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class HuiAreaControlsCardFeature
177177
.map((entityId) => this.hass!.states[entityId] as HassEntity | undefined)
178178
.filter((v): v is HassEntity => Boolean(v));
179179

180-
forwardHaptic("light");
180+
forwardHaptic(this, "light");
181181
toggleGroupEntities(this.hass, entities);
182182
}
183183

src/panels/lovelace/card-features/hui-lock-commands-card-feature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class HuiLockCommandsCardFeature
6969
if (!this.hass || !this._stateObj || !service) {
7070
return;
7171
}
72-
forwardHaptic("light");
72+
forwardHaptic(this, "light");
7373
callProtectedLockService(this, this.hass, this._stateObj, service);
7474
}
7575

0 commit comments

Comments
 (0)