Fix #298 - Esc to close modal

rebase/4.0.0rc2
Eugen Rochko 2016-12-02 14:37:00 +01:00
parent 3114e55c7a
commit d9232959df
1 changed files with 12 additions and 0 deletions

View File

@ -40,6 +40,18 @@ const Lightbox = React.createClass({
mixins: [PureRenderMixin], mixins: [PureRenderMixin],
componentDidMount () {
this._listener = window.addEventListener('keyup', e => {
if (e.key === 'Escape') {
this.props.onCloseClicked();
}
});
},
componentWillUnmount () {
window.removeEventListener(this._listener);
},
render () { render () {
const { intl, isVisible, onOverlayClicked, onCloseClicked, children } = this.props; const { intl, isVisible, onOverlayClicked, onCloseClicked, children } = this.props;