Skip to content

Commit

Permalink
close authorization popup with ESC key or click in backdrop
Browse files Browse the repository at this point in the history
  • Loading branch information
kai-morich committed Jul 24, 2024
1 parent 8e6824c commit 6dbf9fe
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/core/components/auth/authorization-popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -16,7 +30,7 @@ export default class AuthorizationPopup extends React.Component {

return (
<div className="dialog-ux">
<div className="backdrop-ux"></div>
<div className="backdrop-ux" onClick={ this.close }></div>
<div className="modal-ux">
<div className="modal-dialog-ux">
<div className="modal-ux-inner">
Expand Down

0 comments on commit 6dbf9fe

Please sign in to comment.