From 0acab11cf46a9e279d16e803ad32b8aa67e20679 Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Fri, 17 Jul 2015 14:44:13 -0700
Subject: When closing out of a modal, unsaved data and text inside of it is
 erased.

---
 web/react/components/edit_channel_modal.jsx | 3 +++
 1 file changed, 3 insertions(+)

(limited to 'web/react/components/edit_channel_modal.jsx')

diff --git a/web/react/components/edit_channel_modal.jsx b/web/react/components/edit_channel_modal.jsx
index d055feacd..0398dba93 100644
--- a/web/react/components/edit_channel_modal.jsx
+++ b/web/react/components/edit_channel_modal.jsx
@@ -36,6 +36,9 @@ module.exports = React.createClass({
             var button = e.relatedTarget;
             self.setState({ description: $(button).attr('data-desc'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), server_error: "" });
         });
+        $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function() {
+            self.setState({description: ""});
+        })
     },
     getInitialState: function() {
         return { description: "", title: "", channel_id: "" };
-- 
cgit v1.2.3-1-g7c22


From dbbe40e893419d78e23b0d73c8bd6a30478cde2c Mon Sep 17 00:00:00 2001
From: nickago <ngonella@calpoly.edu>
Date: Thu, 23 Jul 2015 09:20:37 -0700
Subject: Added a condition to close event listeners on modals when the
 component is unmounted, and set all unsaved data to be cleared from user
 settings

---
 web/react/components/edit_channel_modal.jsx | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

(limited to 'web/react/components/edit_channel_modal.jsx')

diff --git a/web/react/components/edit_channel_modal.jsx b/web/react/components/edit_channel_modal.jsx
index 0398dba93..a35a531b5 100644
--- a/web/react/components/edit_channel_modal.jsx
+++ b/web/react/components/edit_channel_modal.jsx
@@ -30,15 +30,19 @@ module.exports = React.createClass({
     handleUserInput: function(e) {
         this.setState({ description: e.target.value });
     },
+    handleClose: function() {
+        this.setState({description: "", server_error: ""});
+    },
     componentDidMount: function() {
         var self = this;
         $(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) {
             var button = e.relatedTarget;
             self.setState({ description: $(button).attr('data-desc'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), server_error: "" });
         });
-        $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function() {
-            self.setState({description: ""});
-        })
+        $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', this.handleClose)
+    },
+    componentWillUnmount: function() {
+        $(this.refs.modal.getDOMNode()).off('hidden.bs.modal', this.handleClose)
     },
     getInitialState: function() {
         return { description: "", title: "", channel_id: "" };
-- 
cgit v1.2.3-1-g7c22

