From c408e09a0418c77e1f1f0a91a1c85bf5f20145e7 Mon Sep 17 00:00:00 2001
From: Reed Garmsen <rgarmsen2295@gmail.com>
Date: Wed, 20 Jan 2016 13:16:53 -0800
Subject: Fixed issue with enter key not working in delete post modal

---
 web/react/components/delete_post_modal.jsx | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

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

diff --git a/web/react/components/delete_post_modal.jsx b/web/react/components/delete_post_modal.jsx
index 827654e1b..4cde5feed 100644
--- a/web/react/components/delete_post_modal.jsx
+++ b/web/react/components/delete_post_modal.jsx
@@ -23,7 +23,7 @@ export default class DeletePostModal extends React.Component {
         this.selectedList = null;
 
         this.state = {
-            show: true,
+            show: false,
             post: null,
             commentCount: 0,
             error: ''
@@ -40,6 +40,14 @@ export default class DeletePostModal extends React.Component {
         ModalStore.removeModalListener(ActionTypes.TOGGLE_DELETE_POST_MODAL, this.handleToggle);
     }
 
+    componentDidUpdate(prevProps, prevState) {
+        if (this.state.show && !prevState.show) {
+            setTimeout(() => {
+                $(ReactDOM.findDOMNode(this.refs.deletePostBtn)).focus();
+            }, 0);
+        }
+    }
+
     handleDelete() {
         Client.deletePost(
             this.state.post.channel_id,
@@ -149,10 +157,10 @@ export default class DeletePostModal extends React.Component {
                         {'Cancel'}
                     </button>
                     <button
+                        ref='deletePostBtn'
                         type='button'
                         className='btn btn-danger'
                         onClick={this.handleDelete}
-                        autoFocus='autofocus'
                     >
                         {'Delete'}
                     </button>
-- 
cgit v1.2.3-1-g7c22

