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

Fields default to Blank String #1126

Merged
merged 11 commits into from
Mar 28, 2018
2 changes: 1 addition & 1 deletion src/actions/entries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/Boolean/BooleanControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ BooleanControl.propTypes = {
forID: PropTypes.string,
value: PropTypes.bool,
};

BooleanControl.defaultProps = {
value: false,
};
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export default class RawEditor extends React.Component {

render() {
const { className } = this.props;

return (
<div className="nc-rawEditor-rawWrapper">
<div className="nc-visualEditor-editorControlBar">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export default class MarkdownControl extends React.Component {
value: PropTypes.string,
};

static defaultProps = {
value: '',
};

constructor(props) {
super(props);
editorControl = props.editorControl;
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/Number/NumberControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/Object/ObjectControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export default class ObjectControl extends Component {
forList: PropTypes.bool,
};

static defaultProps = {
value: Map(),
};

constructor(props) {
super(props);
this.state = {
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/Relation/RelationControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class RelationControl extends Component {
setInactiveStyle: PropTypes.func.isRequired,
};

static defaultProps = {
value: '',
};

constructor(props, ctx) {
super(props, ctx);
this.controlID = uuid();
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/Select/SelectControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export default class SelectControl extends React.Component {
}),
};

static defaultProps = {
value: '',
};

handleChange = (e) => {
this.props.onChange(e.target.value);
};
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/String/StringControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ export default class StringControl extends React.Component {
setInactiveStyle: PropTypes.func.isRequired,
};

static defaultProps = {
value: '',
};

render() {
const {
forID,
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/Text/TextControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/components/EditorWidgets/withMedia/withMediaControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default function withMediaControl(forImage) {
value: PropTypes.node,
};

static defaultProps = {
value: '',
};

constructor(props) {
super(props);
this.controlID = uuid();
Expand Down