Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for using Draftail as a controlled component (#180) #207

Merged
merged 16 commits into from
Aug 14, 2019

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
1 participant