diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-02 14:37:00 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2016-12-02 14:37:00 +0100 |
commit | d9232959dff4f9408e9a31bdba4ea565ba292962 (patch) | |
tree | b761634e757712686e93be9b456129ad9dc6d2e9 /app/assets/javascripts/components | |
parent | 3114e55c7a1e1640ed408986ccf3a63267a2653e (diff) |
Fix #298 - Esc to close modal
Diffstat (limited to 'app/assets/javascripts/components')
-rw-r--r-- | app/assets/javascripts/components/components/lightbox.jsx | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/app/assets/javascripts/components/components/lightbox.jsx b/app/assets/javascripts/components/components/lightbox.jsx index 36f078a3a..29822ccb3 100644 --- a/app/assets/javascripts/components/components/lightbox.jsx +++ b/app/assets/javascripts/components/components/lightbox.jsx @@ -40,6 +40,18 @@ const Lightbox = React.createClass({ mixins: [PureRenderMixin], + componentDidMount () { + this._listener = window.addEventListener('keyup', e => { + if (e.key === 'Escape') { + this.props.onCloseClicked(); + } + }); + }, + + componentWillUnmount () { + window.removeEventListener(this._listener); + }, + render () { const { intl, isVisible, onOverlayClicked, onCloseClicked, children } = this.props; |