Draft-js: Strange behaviour on second line after clear all text

Created on 7 Jul 2017  路  1Comment  路  Source: facebook/draft-js

Do you want to request a feature or report a bug?
Bug

How to reproduce:

  1. write some text
  1. clear all text (by set state EditorState.push(this.state.editorState, ContentState.createFromText('')), or EditorState.createEmpty())

  2. write text

  3. insert new line (shift+enter)

  4. write text - some strange behaviour happens

code: https://jsfiddle.net/0oxauau4/
gif: https://giphy.com/gifs/3oKIPzzhEDYgwGVU9q

Draft js 0.10.1 & 0.10.0 & 0.9.0
OS: Mac OS Sierra 10.12.5
Browsers:
Chrome 59.0.3071.115 (64-bit)
Firefox 54.0.1 - I try to test in FF, but got some another problem Error: Got unexpected null or undefined (Draft.js:959)
Safari 10.1.1 - same as in FF

Most helpful comment

I found 'hack' that usage EditorState.moveFocusToEnd fix problem in all browsers.
Code with 'hack' https://jsfiddle.net/60a4df9a/ (line 36)
Also, another way is set hasFocus to true there https://github.com/facebook/draft-js/blob/master/src/model/immutable/SelectionState.js#L141

>All comments

I found 'hack' that usage EditorState.moveFocusToEnd fix problem in all browsers.
Code with 'hack' https://jsfiddle.net/60a4df9a/ (line 36)
Also, another way is set hasFocus to true there https://github.com/facebook/draft-js/blob/master/src/model/immutable/SelectionState.js#L141

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mvnnn picture mvnnn  路  3Comments

roundrobin picture roundrobin  路  3Comments

liran319 picture liran319  路  3Comments

darklightblue picture darklightblue  路  3Comments

abeq picture abeq  路  3Comments