diff --git a/app/javascript/mastodon/components/modal_root.jsx b/app/javascript/mastodon/components/modal_root.jsx index 88a7ac11893..3a79fce9fd9 100644 --- a/app/javascript/mastodon/components/modal_root.jsx +++ b/app/javascript/mastodon/components/modal_root.jsx @@ -59,6 +59,13 @@ class ModalRoot extends PureComponent { } }; + handleBackgroundClick = (e) => { + // Close modal, but only when clicking outside of the modal's content + if (!e.target.matches('.modal-root__container *')) { + this.props.onClose(); + } + } + componentDidMount () { window.addEventListener('keydown', this.handleKeyDown, false); this.history = this.props.history || createBrowserHistory(); @@ -137,7 +144,7 @@ class ModalRoot extends PureComponent { }; render () { - const { children, onClose } = this.props; + const { children } = this.props; const visible = !!children; if (!visible) { @@ -156,9 +163,10 @@ class ModalRoot extends PureComponent { } return ( -