From 794881ce244cbba9ae90e666db29cb99a6d84d45 Mon Sep 17 00:00:00 2001 From: nickago Date: Fri, 21 Aug 2015 09:45:48 -0700 Subject: Upon exiting edit post modal, foucs is placed on the respective text input field --- web/react/components/edit_post_modal.jsx | 7 ++++--- web/react/components/post_info.jsx | 1 + web/react/components/post_right.jsx | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'web') diff --git a/web/react/components/edit_post_modal.jsx b/web/react/components/edit_post_modal.jsx index 064d3fa94..2d865a45d 100644 --- a/web/react/components/edit_post_modal.jsx +++ b/web/react/components/edit_post_modal.jsx @@ -34,6 +34,7 @@ module.exports = React.createClass({ ); $("#edit_post").modal('hide'); + $(this.state.refocusId).focus(); }, handleEditInput: function(editText) { this.setState({ editText: editText }); @@ -52,12 +53,12 @@ module.exports = React.createClass({ var self = this; $(this.refs.modal.getDOMNode()).on('hidden.bs.modal', function(e) { - self.setState({ editText: "", title: "", channel_id: "", post_id: "", comments: 0 }); + self.setState({ editText: "", title: "", channel_id: "", post_id: "", comments: 0, refocusId: "" }); }); $(this.refs.modal.getDOMNode()).on('show.bs.modal', function(e) { var button = e.relatedTarget; - self.setState({ editText: $(button).attr('data-message'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), post_id: $(button).attr('data-postid'), comments: $(button).attr('data-comments') }); + self.setState({ editText: $(button).attr('data-message'), title: $(button).attr('data-title'), channel_id: $(button).attr('data-channelid'), post_id: $(button).attr('data-postid'), comments: $(button).attr('data-comments'), refocusId: $(button).attr('data-refoucsid') }); }); $(this.refs.modal.getDOMNode()).on('shown.bs.modal', function(e) { @@ -65,7 +66,7 @@ module.exports = React.createClass({ }); }, getInitialState: function() { - return { editText: "", title: "", post_id: "", channel_id: "", comments: 0 }; + return { editText: "", title: "", post_id: "", channel_id: "", comments: 0, refocusId: "" }; }, render: function() { var error = this.state.error ?
: null; diff --git a/web/react/components/post_info.jsx b/web/react/components/post_info.jsx index c96a04c7c..73e897f62 100644 --- a/web/react/components/post_info.jsx +++ b/web/react/components/post_info.jsx @@ -49,6 +49,7 @@ export default class PostInfo extends React.Component { role='menuitem' data-toggle='modal' data-target='#edit_post' + data-refoucsid="#post_textbox" data-title={type} data-message={post.message} data-postid={post.id} diff --git a/web/react/components/post_right.jsx b/web/react/components/post_right.jsx index c8c51b0c3..ac4c8a6d7 100644 --- a/web/react/components/post_right.jsx +++ b/web/react/components/post_right.jsx @@ -93,7 +93,7 @@ RootPost = React.createClass({
@@ -203,7 +203,7 @@ CommentPost = React.createClass({
-- cgit v1.2.3-1-g7c22