From 74b0dff86e0093ed1a114e58cd8209969cdebb9c Mon Sep 17 00:00:00 2001 From: Jaden Diefenbaugh <jaden.diefenbaugh@idiap.ch> Date: Tue, 21 Aug 2018 10:50:22 -0700 Subject: [PATCH] [js][tc] fix state refreshing modal when changing block name, closes #146 --- .../src/components/toolchain/ToolchainModal.jsx | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/conda/js/src/components/toolchain/ToolchainModal.jsx b/conda/js/src/components/toolchain/ToolchainModal.jsx index ff7fa184..0828e6a4 100644 --- a/conda/js/src/components/toolchain/ToolchainModal.jsx +++ b/conda/js/src/components/toolchain/ToolchainModal.jsx @@ -59,7 +59,7 @@ type Props = { type State = { }; -class ToolchainModal extends React.PureComponent<Props, State> { +class ToolchainModal extends React.Component<Props, State> { constructor(props: Props){ super(props); } @@ -67,6 +67,14 @@ class ToolchainModal extends React.PureComponent<Props, State> { state = { } + shouldComponentUpdate(nextProps: Props){ + if(nextProps.active !== this.props.active) + return true; + if(nextProps.data !== undefined && nextProps.data !== this.props.data) + return true; + return false; + } + render = () => { const data = this.props.data; if(!data) @@ -229,7 +237,10 @@ class ToolchainModal extends React.PureComponent<Props, State> { </ModalBody> <ModalFooter> <Button block color='danger' - onClick={this.props.deleteBlock} + onClick={(e) => { + this.props.deleteBlock(); + this.props.toggle(); + }} > Delete Block </Button> -- GitLab