icelab / draft-js-autolist-plugin

Automatic unordered/ordered list creation for Facebook’s Draft.js editor.
MIT License
69 stars 13 forks source link

Break out of list not working #10

Open cmoad opened 7 years ago

cmoad commented 7 years ago

Thanks for the plugin. It's been almost an immediate drop-in solution, but I'm unable to break out of lists when hitting enter on an empty line. I did some debugging and can see that the plugin is returning handled on the handleReturn callback when I hit return on an empty line. Any suggestions on how to debug why the block style is not actually toggling off?

https://github.com/icelab/draft-js-autolist-plugin/blob/master/src/index.js#L110

I added a console log in my onChange handler:

console.log('onChange', editorState.getLastChangeType(), RichUtils.getCurrentBlockType(editorState));

On return in an empty line I can see 2 changes happening. The first looks right. The second undoes the removal of the block type.

onChange change-block-type unstyled
onChange split-block unordered-list-item

package.json:

    "draft-js": "^0.10.0",
    "draft-js-autolist-plugin": "^1.0.0",
    "draft-js-plugins-editor": "^2.0.0-beta1",
makenosound commented 7 years ago

@cmoad Ta for the report, I’ll have a look into it. I think I might actually remove this complexity from this plugin and recommend that people use the block breakout plugin instead (as it allows the same functionality across different block types).

cmoad commented 7 years ago

@makenosound Quick update. I gave that plugin a try and it didn't change my issue.

jbonevich commented 7 years ago

Issue still persists as of 2.0.0.

"draft-js": "^0.10.1", "draft-js-autolist-plugin": "^2.0.0", "draft-js-plugins-editor": "^2.0.0-beta1",

cmoad commented 7 years ago

I tried a vanilla create-react-app with the below dependencies and cannot reproduce the issue. I've yet to isolate why my project, which has the identical dependencies, does have the issue. I'll be sure to follow up if I can figure it out.

"draft-js": "^0.10.1", "draft-js-autolist-plugin": "^2.0.0", "draft-js-plugins-editor": "2.0.0-rc5",

makenosound commented 7 years ago

@cmoad Ah, weird. Thanks for the extra info. If you manage to replicate it let me know and I’ll have a look.