UserInfo close by Esc fix
This commit is contained in:
@@ -24,6 +24,20 @@ class UserInfo extends Component {
|
||||
.getUserComments({ user: id, limit: 10 })
|
||||
.then(({ comments = [] }) => this.setState({ comments }))
|
||||
.finally(() => this.setState({ isLoading: false }));
|
||||
|
||||
document.addEventListener('keydown', this.globalOnKeyDown);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
document.removeEventListener('keydown', this.globalOnKeyDown);
|
||||
}
|
||||
|
||||
globalOnKeyDown(e) {
|
||||
// ESCAPE key pressed
|
||||
if (e.keyCode == 27) {
|
||||
const data = JSON.stringify({ isUserInfoShown: false });
|
||||
window.parent.postMessage(data, '*');
|
||||
}
|
||||
}
|
||||
|
||||
render(props, { comments, isLoading }) {
|
||||
|
||||
@@ -151,9 +151,6 @@ function init() {
|
||||
horizontalscrolling="no"
|
||||
/>`;
|
||||
this.iframe = this.node.querySelector('iframe');
|
||||
this.iframe.onload = () => {
|
||||
this.iframe.contentDocument.addEventListener('keydown', this.onKeyDown);
|
||||
};
|
||||
this.node.appendChild(this.closeEl);
|
||||
document.body.appendChild(this.style);
|
||||
document.body.appendChild(this.back);
|
||||
|
||||
Reference in New Issue
Block a user