diff --git a/src/actions/entries.js b/src/actions/entries.js index 5b65f36add5c..a0aed54947a6 100644 --- a/src/actions/entries.js +++ b/src/actions/entries.js @@ -259,7 +259,7 @@ export function createEmptyDraft(collection) { return (dispatch) => { const dataFields = {}; collection.get('fields', List()).forEach((field) => { - dataFields[field.get('name')] = field.get('default', null); + dataFields[field.get('name')] = field.get('default'); }); const newEntry = createEntry(collection.get('name'), '', '', { data: dataFields }); dispatch(emptyDraftCreated(newEntry)); diff --git a/src/components/EditorWidgets/Boolean/BooleanControl.js b/src/components/EditorWidgets/Boolean/BooleanControl.js index 0612a9cc2a98..09a36707587a 100644 --- a/src/components/EditorWidgets/Boolean/BooleanControl.js +++ b/src/components/EditorWidgets/Boolean/BooleanControl.js @@ -38,3 +38,7 @@ BooleanControl.propTypes = { forID: PropTypes.string, value: PropTypes.bool, }; + +BooleanControl.defaultProps = { + value: false, +}; diff --git a/src/components/EditorWidgets/Markdown/MarkdownControl/RawEditor/index.js b/src/components/EditorWidgets/Markdown/MarkdownControl/RawEditor/index.js index cd15da30fb50..eed87f89fd15 100644 --- a/src/components/EditorWidgets/Markdown/MarkdownControl/RawEditor/index.js +++ b/src/components/EditorWidgets/Markdown/MarkdownControl/RawEditor/index.js @@ -51,7 +51,6 @@ export default class RawEditor extends React.Component { render() { const { className } = this.props; - return (
diff --git a/src/components/EditorWidgets/Markdown/MarkdownControl/index.js b/src/components/EditorWidgets/Markdown/MarkdownControl/index.js index b8f427805866..94c723f25e44 100644 --- a/src/components/EditorWidgets/Markdown/MarkdownControl/index.js +++ b/src/components/EditorWidgets/Markdown/MarkdownControl/index.js @@ -21,6 +21,10 @@ export default class MarkdownControl extends React.Component { value: PropTypes.string, }; + static defaultProps = { + value: '', + }; + constructor(props) { super(props); editorControl = props.editorControl; diff --git a/src/components/EditorWidgets/Number/NumberControl.js b/src/components/EditorWidgets/Number/NumberControl.js index c47938f7ff77..f88251f27d5f 100644 --- a/src/components/EditorWidgets/Number/NumberControl.js +++ b/src/components/EditorWidgets/Number/NumberControl.js @@ -15,6 +15,10 @@ export default class NumberControl extends React.Component { max: PropTypes.number, }; + static defaultProps = { + value: '', + }; + handleChange = (e) => { const valueType = this.props.field.get('valueType'); const { onChange } = this.props; diff --git a/src/components/EditorWidgets/Object/ObjectControl.js b/src/components/EditorWidgets/Object/ObjectControl.js index 636287db8004..79a79d3a5d73 100644 --- a/src/components/EditorWidgets/Object/ObjectControl.js +++ b/src/components/EditorWidgets/Object/ObjectControl.js @@ -37,6 +37,10 @@ export default class ObjectControl extends Component { forList: PropTypes.bool, }; + static defaultProps = { + value: Map(), + }; + constructor(props) { super(props); this.state = { diff --git a/src/components/EditorWidgets/Relation/RelationControl.js b/src/components/EditorWidgets/Relation/RelationControl.js index 589892b7fd6c..8cb2d6519753 100644 --- a/src/components/EditorWidgets/Relation/RelationControl.js +++ b/src/components/EditorWidgets/Relation/RelationControl.js @@ -30,6 +30,10 @@ class RelationControl extends Component { setInactiveStyle: PropTypes.func.isRequired, }; + static defaultProps = { + value: '', + }; + constructor(props, ctx) { super(props, ctx); this.controlID = uuid(); diff --git a/src/components/EditorWidgets/Select/SelectControl.js b/src/components/EditorWidgets/Select/SelectControl.js index f9570d7ec88e..748b39f58acc 100644 --- a/src/components/EditorWidgets/Select/SelectControl.js +++ b/src/components/EditorWidgets/Select/SelectControl.js @@ -22,6 +22,10 @@ export default class SelectControl extends React.Component { }), }; + static defaultProps = { + value: '', + }; + handleChange = (e) => { this.props.onChange(e.target.value); }; diff --git a/src/components/EditorWidgets/String/StringControl.js b/src/components/EditorWidgets/String/StringControl.js index 3c13a4cda571..e6db1bdc20de 100644 --- a/src/components/EditorWidgets/String/StringControl.js +++ b/src/components/EditorWidgets/String/StringControl.js @@ -11,6 +11,10 @@ export default class StringControl extends React.Component { setInactiveStyle: PropTypes.func.isRequired, }; + static defaultProps = { + value: '', + }; + render() { const { forID, diff --git a/src/components/EditorWidgets/Text/TextControl.js b/src/components/EditorWidgets/Text/TextControl.js index 93714807d21e..f7da7a09577d 100644 --- a/src/components/EditorWidgets/Text/TextControl.js +++ b/src/components/EditorWidgets/Text/TextControl.js @@ -12,6 +12,10 @@ export default class TextControl extends React.Component { setInactiveStyle: PropTypes.func.isRequired, }; + static defaultProps = { + value: '', + }; + /** * Always update to ensure `react-textarea-autosize` properly calculates * height. Certain situations, such as this widget being nested in a list diff --git a/src/components/EditorWidgets/withMedia/withMediaControl.js b/src/components/EditorWidgets/withMedia/withMediaControl.js index deb1c9de31d4..7cc2c585396d 100644 --- a/src/components/EditorWidgets/withMedia/withMediaControl.js +++ b/src/components/EditorWidgets/withMedia/withMediaControl.js @@ -20,6 +20,10 @@ export default function withMediaControl(forImage) { value: PropTypes.node, }; + static defaultProps = { + value: '', + }; + constructor(props) { super(props); this.controlID = uuid();