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

Commit

Permalink
Default a Field's placeholder to the label
Browse files Browse the repository at this point in the history
Fixes element-hq/element-web#8250

This keeps all fields in line with the design without them having to defining it twice. The option is kept in the first place as some fields might want to override the placeholder to be longer than the label or something.
  • Loading branch information
turt2live committed Jan 25, 2019
1 parent c5deeea commit d819095
Showing 1 changed file with 2 additions and 1 deletion.
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

0 comments on commit d819095

Please sign in to comment.