From 6dbf9fecda2e9efd36781241b0720e83acaced1c Mon Sep 17 00:00:00 2001 From: Kai Morich Date: Wed, 24 Jul 2024 21:30:26 +0200 Subject: [PATCH] close authorization popup with ESC key or click in backdrop --- src/core/components/auth/authorization-popup.jsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/core/components/auth/authorization-popup.jsx b/src/core/components/auth/authorization-popup.jsx index 44ecdee82b9..e0c146bcfa7 100644 --- a/src/core/components/auth/authorization-popup.jsx +++ b/src/core/components/auth/authorization-popup.jsx @@ -2,6 +2,20 @@ import React from "react" import PropTypes from "prop-types" export default class AuthorizationPopup extends React.Component { + handleEvent(event) { + if (event.type === "keydown" && event.key === "Escape") { + this.close() + } + } + + componentDidMount(){ + document.addEventListener("keydown", this) + } + + componentWillUnmount(){ + document.removeEventListener("keydown", this) + } + close =() => { let { authActions } = this.props @@ -16,7 +30,7 @@ export default class AuthorizationPopup extends React.Component { return (
-
+