javascript - React contentEditable and cursor position -


i have simple component

class contenteditable extends react.component{   constructor(props){     super(props);     this.handleinput = this.handleinput.bind(this);   }    handleinput(event) {     let html = event.target.innerhtml;     if(this.props.onchange && html !== this.lasthtml){       this.props.onchange({target:{value: html,name: this.props.name}});       this.lasthtml = html;     } }    render(){     return (<span                 contenteditable="true"                 oninput={ this.handleinput }                 classname={ 'auto '+this.props.classname }                 dangerouslysetinnerhtml={ {__html: this.props.value} }>             </span>);   } } export default contenteditable;  <contenteditable value={this.state.name} onchange={(e)=>{this.setstate({name:e.target.value});}} /> 

component works cursor time on first position instead after rendered text.

i tested examples form forum doesn't work me.

i use react 15.6.1 , test on chrome (os x). hint how can solve problem?


Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -