feat: Escape should dismiss overlay messages (#2324)

This commit is contained in:
Dermot Duffy
2026-01-24 21:39:21 -08:00
committed by GitHub
parent c03ddd9a13
commit 045d15d5ce
+10
View File
@@ -18,11 +18,13 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
super.connectedCallback(); super.connectedCallback();
window.addEventListener('click', this._handleOutsideInteraction); window.addEventListener('click', this._handleOutsideInteraction);
window.addEventListener('focusin', this._handleOutsideInteraction); window.addEventListener('focusin', this._handleOutsideInteraction);
window.addEventListener('keydown', this._handleKeyDown);
} }
public disconnectedCallback(): void { public disconnectedCallback(): void {
window.removeEventListener('click', this._handleOutsideInteraction); window.removeEventListener('click', this._handleOutsideInteraction);
window.removeEventListener('focusin', this._handleOutsideInteraction); window.removeEventListener('focusin', this._handleOutsideInteraction);
window.removeEventListener('keydown', this._handleKeyDown);
super.disconnectedCallback(); super.disconnectedCallback();
} }
@@ -125,6 +127,14 @@ export class AdvancedCameraCardOverlayMessage extends LitElement {
} }
}; };
protected _handleKeyDown = (ev: KeyboardEvent): void => {
if (ev.key === 'Escape') {
this._dismiss();
ev.stopPropagation();
ev.preventDefault();
}
};
static get styles(): CSSResultGroup { static get styles(): CSSResultGroup {
return unsafeCSS(overlayMessageStyle); return unsafeCSS(overlayMessageStyle);
} }