Javascript 对不起作用的羽毛笔进行反应

Javascript 对不起作用的羽毛笔进行反应,javascript,reactjs,onblur,Javascript,Reactjs,Onblur,我正在使用react quill作为react应用程序中的富文本编辑器 我必须将文本编辑器的内容存储在本地React状态,并且只将值发送到Redux“onBlur”。我的问题是,在获得焦点后,如果单击文本编辑器外的按钮,onBlur将无法工作。(即,当单击屏幕上的非交互元素时,onBlur起作用,但当单击“保存”按钮时,onBlur不起作用) 当前代码: class TextEditor extends React.Component { constructor(prop

我正在使用react quill作为react应用程序中的富文本编辑器

我必须将文本编辑器的内容存储在本地React状态,并且只将值发送到Redux“onBlur”。我的问题是,在获得焦点后,如果单击文本编辑器外的按钮,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>
            )           
        }
    }
类文本编辑器扩展了React.Component{
建造师(道具){
超级(道具)
这个州={
内容:this.props.content;
}
this.handleQuillEditor\u change=this.handleQuillEditor\u change.bind(this)
this.handleQuillEditor\u update=this.handleQuillEditor\u update.bind(this)
}
handleQuillEditor_更改(值){
//手变。。。
}
handleQuillEditor\u更新(){
console.log('blur activated!')
}
render(){
常量cmsProps=this.props.cmsProps
返回(
)           
}
}

我的快速修复:将模糊处理程序移动到QuillComponent的container div,如下所示:

            <div style={containerStyle} onBlur={this.handleQuillEditor_update}>

                  <ReactQuill value={this.state.content}
                              onChange={this.handleQuillEditor_change} />

           </div>

我也遇到了同样的错误,我用这堆代码修复了它

<ReactQuill
    onChange={(newValue, delta, source) => {
                if (source === 'user') {
                  input.onChange(newValue);
                 }}}
    onBlur={(range, source, quill) => {
            input.onBlur(quill.getHTML());
           }}
 />
{
如果(源=='用户'){
input.onChange(newValue);
}}}
onBlur={(范围、源、羽毛笔)=>{
onBlur(quill.getHTML());
}}
/>

哇,这看起来是一个真正的解决方案。用“onBlur”将RTE包装在一个div中不适合你吗?我比第二个更喜欢这个答案。更清楚了