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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -