From d409c7c1c6a21de203c471134419726e1c7dcb12 Mon Sep 17 00:00:00 2001 From: Carlos Tadeu Panato Junior Date: Tue, 30 May 2017 22:46:18 +0200 Subject: 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 --- webapp/components/confirm_modal.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'webapp/components/confirm_modal.jsx') 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) { -- cgit v1.2.3-1-g7c22