diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-05-30 22:46:18 +0200 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-05-30 16:46:18 -0400 |
commit | d409c7c1c6a21de203c471134419726e1c7dcb12 (patch) | |
tree | a09bb0065a17f8961ffc3a2b452602ece890b88a /webapp/components/confirm_modal.jsx | |
parent | eab6f7459478d23968466766cbe49185d405a056 (diff) | |
download | chat-d409c7c1c6a21de203c471134419726e1c7dcb12.tar.gz chat-d409c7c1c6a21de203c471134419726e1c7dcb12.tar.bz2 chat-d409c7c1c6a21de203c471134419726e1c7dcb12.zip |
Implement PLT-6246 - Confirm before sending (at)all, (at)channel message (#6250)
* implement PLT-6246 - Confirm before sending (at)all, (at)channel message
* refactor per review
* add constant to define the notify all modal
Diffstat (limited to 'webapp/components/confirm_modal.jsx')
-rw-r--r-- | webapp/components/confirm_modal.jsx | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/webapp/components/confirm_modal.jsx b/webapp/components/confirm_modal.jsx index d6803499a..94f27a3e2 100644 --- a/webapp/components/confirm_modal.jsx +++ b/webapp/components/confirm_modal.jsx @@ -16,11 +16,23 @@ export default class ConfirmModal extends React.Component { } componentDidMount() { - document.addEventListener('keypress', this.handleKeypress); + if (this.props.show) { + document.addEventListener('keypress', this.handleKeypress); + } } componentWillUnmount() { - document.removeEventListener('keypress', this.handleKeypress); + if (!this.props.show) { + document.removeEventListener('keypress', this.handleKeypress); + } + } + + componentWillReceiveProps(nextProps) { + if (this.props.show && !nextProps.show) { + document.removeEventListener('keypress', this.handleKeypress); + } else if (!this.props.show && nextProps.show) { + document.addEventListener('keypress', this.handleKeypress); + } } handleKeypress(e) { |