Skip to content

Conversation

@thibaudcolas
Copy link
Collaborator

@thibaudcolas thibaudcolas commented Aug 10, 2019

Fixes #180 (comment). This implements:

  • Two new props on DraftailEditor, editorState and onChange.
  • onChange is called instead of setState in the editor’s onChange, with the filtered editor state as a parameter.
  • If onChange is set, onSave is never called.
  • editorState is the value that the editor renders, effectively replacing this.state.editorState.

The editor’s code was rewritten to use a getEditorState method, either retrieving the local state or the state from props depending on which scenario applies.

I have two more things to figure out:

  • Should the editor expose its state conversion functions for reuse by implementers
  • Should the "controlled" or "uncontrolled" API be recommended in the documentation

@thibaudcolas thibaudcolas added the enhancement New feature or request label Aug 10, 2019
@thibaudcolas thibaudcolas added this to the v1.3.0 milestone Aug 10, 2019
@lgtm-com
Copy link

lgtm-com bot commented Aug 14, 2019

This pull request introduces 1 alert when merging b84375a into 0995151 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

@thibaudcolas thibaudcolas merged commit efb29b3 into master Aug 14, 2019
@thibaudcolas thibaudcolas deleted the feature/controlled-component branch August 14, 2019 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Controlled component

2 participants