React-quill: onBlur not working

Created on 30 Oct 2017  路  3Comments  路  Source: zenoamaro/react-quill

I have a TextEditor component that locally stores the content of ReactQuill, and I only want to send the content value to Redux 'onBlur'. The Blur event seems to work fine EXCEPT when clicking buttons on the screen screen. (E.g., when I write something in a ReactQuill component and then click a "save" button).

Current Code:

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>
        )           
    }
}

Most helpful comment

My solution was to move the blur handler to the div that wraps ReactQuill

All 3 comments

My solution was to move the blur handler to the div that wraps ReactQuill

Going to consider this a duplicate of #276 - discussing future handling of blur events there

My solution was to move the blur handler to the div that wraps ReactQuill

You saved my day!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LiuChangFreeman picture LiuChangFreeman  路  3Comments

andylacko picture andylacko  路  5Comments

pooriamo picture pooriamo  路  3Comments

camliu89 picture camliu89  路  4Comments

Drejerdk picture Drejerdk  路  4Comments