Skip to content

Commit

Permalink
Fix #584
Browse files Browse the repository at this point in the history
  • Loading branch information
yishn committed Feb 29, 2020
1 parent 7fae719 commit bccc8c0
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/components/sidebars/CommentBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,20 +249,29 @@ export default class CommentBox extends Component {
this.handleCommentInput = () => {
let {onCommentInput = noop} = this.props

this.setState({
let data = {
title: this.titleInputElement.value,
comment: this.textareaElement.value
})
}

this.setState(data)

clearTimeout(this.commentInputTimeout)
this.commentInputTimeout = setTimeout(() => {
onCommentInput({
title: this.titleInputElement.value,
comment: this.textareaElement.value
})
onCommentInput(data)
}, commentsCommitDelay)
}

this.handleCommentBlur = () => {
let {onCommentInput = noop} = this.props

clearTimeout(this.commentInputTimeout)
onCommentInput({
title: this.titleInputElement.value,
comment: this.textareaElement.value
})
}

this.handleMenuButtonClick = () => {
let {left, bottom} = this.menuButtonElement.getBoundingClientRect()
let {treePosition} = this.props
Expand Down Expand Up @@ -357,7 +366,8 @@ export default class CommentBox extends Component {
name: 'title',
value: title,
placeholder: t('Title'),
onInput: this.handleCommentInput
onInput: this.handleCommentInput,
onBlur: this.handleCommentBlur
})
)
),
Expand All @@ -366,7 +376,8 @@ export default class CommentBox extends Component {
ref: el => (this.textareaElement = el),
placeholder: t('Comment'),
value: comment,
onInput: this.handleCommentInput
onInput: this.handleCommentInput,
onBlur: this.handleCommentBlur
})
)
)
Expand Down

0 comments on commit bccc8c0

Please sign in to comment.