Browse Source

Fix #298 - Esc to close modal

closed-social-v3
Eugen Rochko 8 years ago
parent
commit
d9232959df
1 changed files with 12 additions and 0 deletions
  1. +12
    -0
      app/assets/javascripts/components/components/lightbox.jsx

+ 12
- 0
app/assets/javascripts/components/components/lightbox.jsx View File

@ -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;

Loading…
Cancel
Save