Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Default a Field's placeholder to the label #2503

Merged
merged 1 commit into from
Jan 25, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/components/views/elements/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default class Field extends React.PureComponent {
type: PropTypes.string,
// The field's label string.
label: PropTypes.string,
// The field's placeholder string.
// The field's placeholder string. Defaults to the label.
placeholder: PropTypes.string,
// The type of field to create. Defaults to "input". Should be "input" or "select".
// To define options for a select, use <Field><option ... /></Field>
Expand Down Expand Up @@ -55,6 +55,7 @@ export default class Field extends React.PureComponent {
// Set some defaults for the element
extraProps.type = extraProps.type || "text";
extraProps.ref = "fieldInput";
extraProps.placeholder = extraProps.placeholder || extraProps.label;

const element = this.props.element || "input";
const fieldInput = React.createElement(element, extraProps, this.props.children);
Expand Down