feat: Escape ends calls (#2488)

This commit is contained in:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent 9b750953ae
commit 881ba51e9f
2 changed files with 29 additions and 3 deletions
+18
View File
@@ -49,6 +49,16 @@ export class AdvancedCameraCardCallControls extends LitElement {
@state()
private _exiting = false;
public connectedCallback(): void {
super.connectedCallback();
window.addEventListener('keydown', this._handleKeyDown);
}
public disconnectedCallback(): void {
window.removeEventListener('keydown', this._handleKeyDown);
super.disconnectedCallback();
}
protected willUpdate(changedProps: PropertyValues): void {
if (changedProps.has('buttonSize') && this.buttonSize) {
this.style.setProperty(
@@ -113,6 +123,14 @@ export class AdvancedCameraCardCallControls extends LitElement {
</div>`;
}
private _handleKeyDown = (ev: KeyboardEvent): void => {
if (this.active && ev.key === 'Escape') {
dispatchActionExecutionRequest(this, { actions: createCallEndAction() });
ev.stopPropagation();
ev.preventDefault();
}
};
private _handleAnimationEnd = (ev: AnimationEvent): void => {
if (hasPopOutAnimationEnded(ev)) {
this._exiting = false;