diff options
author | Corey Hulen <corey@hulen.com> | 2016-02-04 15:36:28 -0800 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2016-02-04 15:36:28 -0800 |
commit | 392b878a108492a56cbc2ed68acc7130cac96c0d (patch) | |
tree | 71bd17bbd191d0e010ea38e4c5e902cde635c61e /web/react/components/create_comment.jsx | |
parent | af6ade338002a215ff7c7771f7fe6bbbb06f0cd7 (diff) | |
parent | c4344f8c02227f77165f4592e0c87c323b7e00f5 (diff) | |
download | chat-392b878a108492a56cbc2ed68acc7130cac96c0d.tar.gz chat-392b878a108492a56cbc2ed68acc7130cac96c0d.tar.bz2 chat-392b878a108492a56cbc2ed68acc7130cac96c0d.zip |
Merge pull request #2071 from hmhealey/plt1820
PLT-1820/PLT-1847 Cleaned up textbox focus code
Diffstat (limited to 'web/react/components/create_comment.jsx')
-rw-r--r-- | web/react/components/create_comment.jsx | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/web/react/components/create_comment.jsx b/web/react/components/create_comment.jsx index 8c49315e7..9e7c67515 100644 --- a/web/react/components/create_comment.jsx +++ b/web/react/components/create_comment.jsx @@ -51,6 +51,7 @@ class CreateComment extends React.Component { this.commentMsgKeyPress = this.commentMsgKeyPress.bind(this); this.handleUserInput = this.handleUserInput.bind(this); this.handleKeyDown = this.handleKeyDown.bind(this); + this.handleUploadClick = this.handleUploadClick.bind(this); this.handleUploadStart = this.handleUploadStart.bind(this); this.handleFileUploadComplete = this.handleFileUploadComplete.bind(this); this.handleUploadError = this.handleUploadError.bind(this); @@ -74,6 +75,8 @@ class CreateComment extends React.Component { componentDidMount() { PreferenceStore.addChangeListener(this.onPreferenceChange); window.addEventListener('resize', this.handleResize); + + this.refs.textbox.focus(); } componentWillUnmount() { PreferenceStore.removeChangeListener(this.onPreferenceChange); @@ -94,6 +97,10 @@ class CreateComment extends React.Component { $('.post-right__scroll').perfectScrollbar('update'); } } + + if (prevProps.rootId !== this.props.rootId) { + this.refs.textbox.focus(); + } } handleSubmit(e) { e.preventDefault(); @@ -218,6 +225,9 @@ class CreateComment extends React.Component { }); } } + handleUploadClick() { + this.refs.textbox.focus(); + } handleUploadStart(clientIds) { let draft = PostStore.getCommentDraft(this.props.rootId); @@ -225,6 +235,10 @@ class CreateComment extends React.Component { PostStore.storeCommentDraft(this.props.rootId, draft); this.setState({uploadsInProgress: draft.uploadsInProgress}); + + // this is a bit redundant with the code that sets focus when the file input is clicked, + // but this also resets the focus after a drag and drop + this.refs.textbox.focus(); } handleFileUploadComplete(filenames, clientIds) { let draft = PostStore.getCommentDraft(this.props.rootId); @@ -365,6 +379,7 @@ class CreateComment extends React.Component { <FileUpload ref='fileUpload' getFileCount={this.getFileCount} + onClick={this.handleUploadClick} onUploadStart={this.handleUploadStart} onFileUpload={this.handleFileUploadComplete} onUploadError={this.handleUploadError} |