Skip to content
This repository was archived by the owner on Dec 11, 2019. It is now read-only.

Commit 9a5e96c

Browse files
committed
popup window should close on escape
auditors: @bbondy
1 parent 42c89e6 commit 9a5e96c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

js/components/popupWindow.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const React = require('react')
66
const ReactDOM = require('react-dom')
77
const ImmutableComponent = require('./immutableComponent')
88
const cx = require('../lib/classSet.js')
9+
const KeyCodes = require('../constants/keyCodes')
910
const windowActions = require('../actions/windowActions')
1011

1112
/**
@@ -20,7 +21,18 @@ class PopupWindow extends ImmutableComponent {
2021
this.left = this.props.detail.get('left')
2122
}
2223

24+
onKeyDown (e) {
25+
if (e.keyCode === KeyCodes.ESC || e.keyCode === KeyCodes.TAB) {
26+
windowActions.setPopupWindowDetail()
27+
}
28+
}
29+
30+
componentWillUnmount () {
31+
window.removeEventListener('keydown', this.onKeyDown.bind(this))
32+
}
33+
2334
componentDidMount () {
35+
window.addEventListener('keydown', this.onKeyDown.bind(this))
2436
let src = this.props.detail.get('src')
2537
if (src) {
2638
let webview = document.createElement('webview')

0 commit comments

Comments
 (0)