【发布时间】:2017-10-30 15:17:37
【问题描述】:
我在 react 应用程序中使用 react-quill 作为富文本编辑器。
我必须将文本编辑器的内容存储在本地 React 状态,并且只将值发送到 Redux 'onBlur'。我的问题是,当您在获得焦点后单击文本编辑器之外的按钮时,onBlur 将不起作用。 (即 onBlur 在点击屏幕上的非交互元素时有效,但在点击“保存”按钮时无效)。
当前代码:
class TextEditor extends React.Component {
constructor(props) {
super(props)
this.state={
content: this.props.content;
}
this.handleQuillEditor_change = this.handleQuillEditor_change.bind(this)
this.handleQuillEditor_update = this.handleQuillEditor_update.bind(this)
}
handleQuillEditor_change (value) {
// handleChange...
}
handleQuillEditor_update () {
console.log('blur activated!')
}
render() {
const cmsProps = this.props.cmsProps
return (
<div style={containerStyle}>
<ReactQuill value={this.state.content}
onChange={this.handleQuillEditor_change}
onBlur={this.handleQuillEditor_update}/>
</div>
)
}
}
【问题讨论】:
标签: javascript reactjs onblur